I have these in my file:
JOS BUTTLER
JASON ROY
DAWID MALAN
JONNY BAISTROW
BEN STOKES
in different lines. And I want them to extract in my program to print them on the exact way they are in file. My imaginary output screen is:
JOS BUTTLER
JASON ROY
DAWID MALAN
JONNY BAISTROW
BEN STOKES
How would I do it using fscanf() and printf(). Moreover suggest me the way to change the delimiters of fscanf() to \n
I have tried something like this:
char n[5][30];
    printf("Name of 5 cricketers read from the file:\n");
   for(i=0;i<5;i++)
   { 
            fscanf(fp,"%[^\n]s",&n[i]);
            printf("%s ",n[i]);         
    }
    fclose(fp);
}
But it works only for the first string and other string could not be displayed. There were garbage values.
 
     
    