I don't know what's wrong but the succeeding strings are not properly read by fgets.
else {
initArray(word1); //first string
fgets(word1, 29, fileIn);
printf("word1: %s\n", word1);
len = strlen(word1);
if(word1[len-1] == '\n')
word1[len-1] = '\0';
while(!feof(fileIn)) { //succeeding strings in next line
initArray(word1);
fgets(word1, 30, fileIn);
printf("word1: %s\n", word1);
len = strlen(word1);
if(word1[len-1] == '\n')
word1[strlen(word1)-1] = '\0';
fgetc(fileIn);
}
fclose(fileIn);
}
}
texts:
ABCD
asnjf
fkj
read:
ABCD
snjf
kj
Can you give me an idea what's wrong?