Hi, I need to open a file containing string values one below the other and display them.
I'm able to open the file but there is some error while displaying them.
Below is my code, kindly guide me to my mistake.
FILE *fp;
char airfoil[6];
fp=fopen("/cygdrive/d/airfoil.txt","r");
if(fp!=NULL)
{
while (feof(fp)==0)
{
for(i=0;i<6;i++)
{
fscanf(fp,"%s",&airfoil[i]);
}
}
for(i=0;i<6;i++)
{
printf("%s\n",airfoil[i]);
}
}/*end of if*/
fclose(fp);
The values in my airfoil text file is:
abc
bcd
cde
def
efg
fgh
P.S: I'm using Netbeans with Cygwin.