Advertisement
Dlrowniatrec_2110

sample12-2c

Jun 18th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.47 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main(){
  6.     FILE *fptr;
  7.    
  8.     char input[81], filename[20];
  9.     printf("請輸入欲寫入的姓名: ");
  10.     gets(filename);
  11.     fptr = fopen(filename, "w");
  12.    
  13.     puts("請輸入字串,當字串為 quit 表示結束:\n");
  14.    
  15.     while(strcmp(gets(input), "quit") != 0){
  16.         fputs(input, fptr);
  17.         fputc('\n', fptr);
  18.     }
  19.     fclose(fptr);
  20.     system("PAUSE");
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement