Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!mintaka!ogicse!milton!amigo From: amigo@milton.u.washington.edu (The Friend) Newsgroups: comp.lang.c Subject: reading from a file.sorting Keywords: files/sorting Message-ID: <1991Apr3.090427.25624@milton.u.washington.edu> Date: 3 Apr 91 09:04:27 GMT Article-I.D.: milton.1991Apr3.090427.25624 Organization: University of Washington Lines: 32 I'm looking for a simple program that'll read ten words from a string that has only got spaces between the words. I had one example that had pointers - data read in via fscanf, then the pointer was copied to another pointer array (each array held one word). After the 10 words were read, the array was simply incremented backwards in a for loop to print out correctly. The problem? it didn't work. Guess I need more expierence. I've got little resources on file opening unfortuntely. To start the program I have: FILE *fp; static char *data; static char *data_array[11]; int i; main(){ fp=fopen("test","r"); for(i=0;i<10;i++){ fscanf(fp,"%s", data); from there I get lost.. ya I have the data read - hopefully word by word (?).. I can use strcpy() to copy between pointers (?), the printout of the array after that is easy.. -- --------------------------------------------------------------------- amigo@milton.u.washington.edu ---------------------------------------------------------------------