guys..I would like to ask for some help. Im trying to read 10 integers in a text file and store it in a array. the problem is when I display it the numbers are treated one by one instead of putting them all together. For example when I display array[0] which is suppose to be 100 the outputs are:
a[0] =1
a[1] =0
a[2] =0
get my point?
I would like to ask for some advice on how to do it correctly. heres a piece of my code:
char ch;
int size=10;
int myArray[size];
ifstream myfile;
myfile.open("numbers.txt");
while(!myfile.eof())
{
myfile.get(ch);
for(int i=0; i<10; i++)
{
myArray[i]=ch;
cout<<myArray[i]<<" ";
}
}
the output should be:
100 0 -3 77 55 2 -10 4 67 34
but the output I have is:
1 0 0 0 -3 7 7 5 5 and so on.....
thanks guys