My program is having a hard time reading an input. Whenever I run the program, the output file becomes a mass of symbols, Can anyone please tell me what I'm doing wrong?
Why the C-strings instead of the safer std::string?
You are probably outputting uninitialized values to your output file, since you have changed the index value between the input and the output statements.
My input file is:
AAPL
Apple Computer
27
LU
Lucent Technologies
72
NSCP
Netscape
27.75
MOT
Motorola
49.5
The output I get is always:
ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌAAPL
-9.25596e+6
Also, for the C-strings, I'm using namespace std, since I'm still setting it up
Using getline and the extraction operator (>>) together can cause problems. Either get all input via getline and convert numbers from strings, or skip any left-over whitespace with std::ws.