Friday, 27 September 2013

How do you save the characters of a file into a string or array

How do you save the characters of a file into a string or array

For example, if I had a file name random.txt, which read:
This is a string. Abc Zxy
How would you save the characters in random.txt to a string or array that
includes all of the characters in the text file?
So far I have (using redirection for file)
include
include
int main () { int c;
do {
c = fgetc(stdin);
putchar(c);
} while (c != EOF);
return 0;
}

No comments:

Post a Comment