Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main() {
- char s[10001]; // 10k letters, 1 for null char
- // read spaces also in the string (the whole line)
- // no & in scanf before string (char arrays) names
- scanf("%[^\n]", s);
- FILE *f = fopen("file.txt", "w");
- if (f == NULL) {
- printf("Error opening file!\n");
- exit(1);
- }
- fprintf(f, "%s\n", s);
- fclose(f);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement