here...theres something wrong it doesnt read all of the file and displays some annoying numbers..i think my code now is right but it isnt when i run the program..whats wrong with it?
#include<iostream.h>
#include<cstring.h>
#include<fstream.h>
struct grocery
{
int barcode;
string prodname;
string category;
float price;
} ;
int main()
{
grocery data[50];
ifstream in;
in.open("grocery.txt");
for(int i = 0;i<50; i++) //this can also be written as for(int i = 0; i < 50; i++) since the size is 50
{
in >> data[i].barcode >> data[i].prodname >> data[i].category >> data[i].price;
}
in.close();
for(int ind = 0;ind<50; ind++)
cout<<data[ind].barcode<<""<<data[ind].prodname<<""<<data[ind].category<<""<<data[ind].price;
return 0;
}