mikeeeblue
Programmer
Hey all
I want to read all the characters from a txt file into a char array, however the problem is is with the code i am currently using i need to set the array size of the char array and if the file has more characters in than the amount of elements declared in the char array then some of the file wont be read in. Do you know how to solve this problem? Thanks btw im using windows
char s[2000];
fstream file_op("c:/test.txt",ios::in);
while(!file_op.eof())
{
file_op.getline(s,2000);
cout <<s;
} file_op.close();
cout <<endl;
I want to read all the characters from a txt file into a char array, however the problem is is with the code i am currently using i need to set the array size of the char array and if the file has more characters in than the amount of elements declared in the char array then some of the file wont be read in. Do you know how to solve this problem? Thanks btw im using windows
char s[2000];
fstream file_op("c:/test.txt",ios::in);
while(!file_op.eof())
{
file_op.getline(s,2000);
cout <<s;
} file_op.close();
cout <<endl;