View Single Post
Old 09-22-07, 10:50 PM   #10
Imbroglio's Avatar
Join Date: Mar 2004
Posts: 1,271
Default Re: C++ Gurus, School Me :D

Originally Posted by six_storm
Ok, I got everything worked out. Now my problem is indentation. I'm supposed to take an input file and meet the following conditions when outputting to the screen and output.txt:

1) When a "{" passes thru, go to the next line and indent 6 spaces.
2) When a "}" passes thru, go to the next line and dedent 6 spaces.
3) If you have a nested or two "{", go to next line and indent 12 spaces.

What I can't figure out is how can you tell your program where the end of the line is to "endl;". Any takers? TIA.
why not just use getline? and then parse it per the tokens you want?

syntax is getline(stream, string var);

the function reads the entire line until '\n' is hit and puts it into the string variable (if i remember correctly '\n' is trunced from the end of the string, so you may or may not need to add it depending on formatting specs)

HT: 360 -- Sony60A3000 -- Onkyo SR605 --> Polk cs2, monitor 60s and monitor 40s w/ Bic F12 sub -- PS3
XBL:Mr X3r0 -- PSN:Mr_X3r0

Rig- Asus P6X58D Premium - intel i7 920 @3.6 - EVGA GTX570 - Corsair HX1000 - Prolimatech Mega Shadow - WD640 - COOLER MASTER ATCS 840 - OCZ Gold 6GB DDR3 1600*

Imbroglio is offline   Reply With Quote