reading from a file.sorting
The Friend
amigo at milton.u.washington.edu
Wed Apr 3 19:04:27 AEST 1991
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 at milton.u.washington.edu
---------------------------------------------------------------------
More information about the Comp.lang.c
mailing list