C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C fputs() and fgets()The fputs() and fgets() in C programming are used to write and read string from stream. Let's see examples of writing and reading file using fgets() and fgets() functions. Writing File : fputs() functionThe fputs() function writes a line of characters into file. It outputs string to a stream. Syntax: int fputs(const char *s, FILE *stream) Example: #include myfile2.txt hello c programming Reading File : fgets() functionThe fgets() function reads a line of characters from file. It gets string from a stream. Syntax: char* fgets(char *s, int n, FILE *stream) Example: #include Output: hello c programming
Next TopicC fseek()
|