I'm reading in a text file. I'm reading it one character at a time. How do I append the char I just read to the end of a string?
Here is what I've got (the appending part I can't figure out):
{
char field[40];
FILE *stream, *fopen();
stream = fopen("fisc.txt","r");
if ( (stream) == NULL)
{
printf("Can't open %sn","fisc.txt");
exit(1);
}
else
{
char ch;
int counter;
counter = 1;
do
{
ch = fgetc(stream);
//printf("In the else %c\n", ch);
if (ch != "|")
{
field[counter] = ch;
++counter;
printf("%s\n", field);
}
}
while (ch != EOF);
}
fclose(stream);
}
Any help or suggestions are greatly appreciated.