file problem (I have never seen this before)
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:
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 my Text file:
Code:
one
two
three
1
2
3
Here is what I get when I compile/run my program:
[CODE[one
two
three
1
2
3_¦
¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦tÇB[/CODE]
Anybody know what's going on?