Lets say I have a txt file list.txt
The txt file has list of integers ,
88
894
79
35
Now I am able to open the file and display the contents in it but not able to store it in an integer array.
int main()
{
ifstream fin;
fin.open("list.txt");
char ch;
int a[4],i=0;
while((!fin.eof())&&(i<4))
{
fin.get(ch);
a[i]=(int)ch;
cout<<a[i]<<"\n";
i++;
}
fin.close();
return 0;
}
Please help!!