IHYPRESS PROGRAMMING
Tutorials and C programs with code and output for beginners
c programming
HOME | ASP | C | CSS | GNUPLOT | HTML | JAVASCRIPT | PERL | PHP | PYTHON | RUBY | SVG
CStrings : Reading from a File
<08.03>
/* Reading a string from a file */
#include <stdio.h> #include <string.h> int main (void) { char sentence[200]; FILE *input; /* file is opened */ input = fopen("phrase.txt", "r"); /* the string is read from the file */ fgets (sentence, sizeof(sentence), input); /* sentence is echoed on the screen */ /* \" to display a " (double quotes) */ printf ("The sentence is:\n\"%s\"\n\n\n", sentence); /* file is closed */ fclose (input); return (0); }
Hergestellt in Deutschland / Made in Germany
The sentence is: "The quick brown fox."
COPYRIGHT © 2015-2024 IHY PRESS Frankfurt am Main 60329 Deutschland