1

I get the right input, but its giving out the numbers unformatted in the output ie: when it should be
input:
3 5 (7)
$58 3,400

output:
3 5 -7
58 3400

it gives me
3
5
-7

5
8


3
4
0
0

inFile.get(aa);
while( ! inFile.eof())
{
	switch(aa)
	{
		case '$':
			break;
		case ',':
			break;
		case '(':
			outFile << '-';
			break;
		case ')':
			break;
		case '\t':
			break;
		default:
			outFile << aa << endl;
			break;
	}
	inFile.get(aa);

}

inFile.close();
outFile.close();
Votes + Comments
using code tags correctly the first time :)
5
Contributors
5
Replies
6
Views
9 Years
Discussion Span
Last Post by gregorynoob
0

Look at the statement:

outFile << aa << endl;

<<endl prints newline and flushes output buffer. That's why your program prints every char on the new line...

0

well... i'm not that good with c++ I/O (c ftw), but if you're using fstream, you can make two streams and use them for I/O, for example if the input stream is called 'input' you can go with

while( input >> aa ) {/*blahblah...*/}

...well i guess you can... hmm, i'm all sleepy, maybe i just made it all up
//edit: btw i think it's lookin for eof this way too, cause input is true while there's something to input, but when the file's empty...oops.. return 0; kkthxbai

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.