Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!dali.cs.montana.edu!milton!amigo From: amigo@milton.u.washington.edu (The Friend) Newsgroups: comp.lang.c Subject: whats wrong with this? Message-ID: <1991Apr4.063341.20957@milton.u.washington.edu> Date: 4 Apr 91 06:33:41 GMT Organization: University of Washington Lines: 36 Follow-up To: sender I have a program that >should< read characters from a file, since the file contains 10 words with spaces to seperate them, I've got a while loop looking for that. The for-loop does the job of updating the array to the next level, and since we know there's 10 words, it should work a-ok. Here's what we have: FILE *fp; char data, data_array[11][11]; int i,j; if((fp=fopen("test.dat","r"))==NULL){ printf("\n\nOoops..some error..\n\n"); exit(0); } for(i=0;i<10;i++){ while((data=getc(fp))!=' '){ data_array[i][j]=data; j++; } j=0; } Where's the problem with this? Can someone recommend a better solution to reading it in and putting it into arrays? Any help's appreciated - please mail it to me.. Thanks. -- --------------------------------------------------------------------- Scott Rowin /--/ amigo@milton.u.washington.edu __////