Hi, I'm trying to break a line up into individual chars. This is what I tried but it doesn't work!:
File *fp;
char lines[100];
fgets(fp, lines, 100);
length = strlen(lines)
for(i=0; i<length-1; i++) // print each individual char
printf("%s\n", length[i]);
If the file I read contained:
abcd
When I print the contents of the char array line[], I thought
I would get:
line[1] = a
line[2] = b
line[3] = c
line[4] = d
But instead I get:
line[1] = abcd
line[2] = bcd
line[3] = cd
line[4] = d
I know in java I have used a 'charAt' function to do this. Does C have something similar in the string.h library? Thanks in advance for any help.