Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <math.h>
- void saveWordsToFileFromStdin(char *);
- int main(void)
- {
- char name[15];
- scanf("%15s\n", name);
- saveWordsToFileFromStdin(name);
- return 0;
- }
- void saveWordsToFileFromStdin(char *fileName)
- {
- FILE *file = fopen(fileName, "w");
- char buffer[20];
- while (fgets(buffer, sizeof(buffer), stdin))
- {
- if (strcmp(buffer, "\n") == 0)
- break;
- fprintf(file, "%s", buffer);
- }
- fclose(file);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement