I have my code to read a text file and it reads the txt fine, but after the text, it displays these funny characters. Here's my code:
Here is my Text file:Code:#include <iostream.h> #include <fstream.h> #include <stdio.h> int main() { ifstream file("text.txt"); char array[50]; int i=0; while((!file.eof())&&(i < 49)) { file.get(array[i]); ++i; } array [i +1] = '\n'; cout << array; return 0; }
Here is what I get when I compile/run my program:Code:one two three 1 2 3
[CODE[one
two
three
1
2
3_¦
¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦tÇB[/CODE]
Anybody know what's going on?