Bloosy
Technical User
- Jun 23, 2003
- 15
Hi everybody. I want to put 4 strings from a file into a two-dimensional array. This is how I declared it:
I intend to have a file wich stores 10 suppliers, all having 4 attributes: Name, Address, Contact and Telefone.
I have edited the file suppliers.txt, each supplier in one row, attributes separated with space. I have then tried this:
just to test one row at least. I have included all necessary headers, program compiles and links ok, but fails to run with a message "...Wholesale.exe has encountered a problem and needs to close. We are sorry for the inconvenience". Could anyone tell me what's wrong
Thanks
Code:
char* suppliers[10][4];
I have edited the file suppliers.txt, each supplier in one row, attributes separated with space. I have then tried this:
Code:
int main() {
ifstream infile;
infile.open("suppliers.txt");
if(!infile) {cout<<"File couldn't be opened"; exit(1);}
int i = 0;
infile>>suppliers[i][0]>>suppliers[i][1]>>suppliers[i][2]>>suppliers[i][3];
infile.close();
just to test one row at least. I have included all necessary headers, program compiles and links ok, but fails to run with a message "...Wholesale.exe has encountered a problem and needs to close. We are sorry for the inconvenience". Could anyone tell me what's wrong
Thanks