[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/sci/ - Science & Math


View post   

File: 63 KB, 629x848, 1284376728962.jpg [View same] [iqdb] [saucenao] [google]
1782191 No.1782191 [Reply] [Original]

hey /sci/

need some basic C++ help.

I'm using fstream to read email addresses from a text file and evaluate them. The way it works, it grabs each line in order and I run functions on it to see if it's valid. Problem is, some of the "email addresses" have spaces in them, and this stops the reader prematurely. How can I make my program treat the spaces as a regular character and only stop at the line ends?

>> No.1782204
File: 114 KB, 1084x777, 1284376190228.jpg [View same] [iqdb] [saucenao] [google]
1782204

bamp with science

>> No.1782248

I don't understand the problem.

Just make your own check functions and change the halt condition from space to endl.

...can you even put spaces in emails? (has never tried)

>> No.1782279

Put this in your code, send it to the grader for an easy A

while (1)
     system ( "start www.4chan.org/b");

>> No.1782296

i remember having a similar issue
if each of the email addresses has a TAB at the end (like, pressing enter when typing goes to the next line)

then just look for the End of Line character (forget what it is) but just check every character against it. when you run into one, stop the loop

>> No.1782355

Use the getline() method to grab everything up to the next newline character.

Also, why do your email addresses have spaces in them?

>> No.1782361

>>1782355
Forgot to give you a link: http://www.cplusplus.com/reference/iostream/istream/getline/

>> No.1782375

>>1782355
they have spaces because they are given incorrect email addresses, the program has to determine them so in another text document though.

getline(file, line);

?

>> No.1782393

>>1782375
fstream fin;
char s[kmaxsize];
fin.getline(s, kmaxsize);

or, if you want to specify the delimiter explicitly
fin.getline(s, kmaxsize, '\n');

>> No.1782416

>>1782355
>>1782375

n00bs, read the fucking RFC. Email addresses can contain ANY FUCKING CHARACTER. Not only that, they can contain FUCKING NESTED COMMENTS.

Of course, nobody reads the fucking RFC, so nobody actually implements proper email addresses, except the people who do, resulting in email addresses not having a standard at all because the actual standard is ridiculous.

Anyways, here you go OP:

http://codepad.org/BnZ47WCo

>> No.1782446

>>1782416
Not the local part. Plus there are informal restrictions which are in practice placed on quoted strings (in part because of interoperability concerns, and in part because of past associated security risks).

>While the above definition for Local-part is relatively permissive, for maximum interoperability, a host that expects to receive mail SHOULD avoid defining mailboxes where the Local-part requires (or uses) the Quoted-string form or where the Local-part is case-sensitive. For any purposes that require generating or comparing Local-parts (e.g., to specific mailbox names), all quoted forms MUST be treated as equivalent, and the sending system SHOULD transmit the form that uses the minimum quoting possible.

>> No.1782562
File: 153 KB, 544x400, 1281833268000.jpg [View same] [iqdb] [saucenao] [google]
1782562

thanks all, I got it working

>> No.1783078

>>1782191

But, but, but, planes are made of aluminium and titanium and carbon fibre reinforced plastics and other composites - none of which are magnetic.

SO HOW DOES THIS WORK????!?!!???11???