C语言 键盘输入字符 写入文件

来源:互联网 发布:samsung打印服务软件 编辑:程序博客网 时间:2024/05/18 18:43

#include <stdio.h>#include <stdlib.h>main(){    char str1[50], str2[50];    int i;    FILE *fp;        gets(str1);    gets(str2);        fp=fopen("lhsbqb.txt","w");    if(fp==NULL){printf("File open faild");exit(0);}    for(i=0;str1[i]!='\0';i++)        fputc(str1[i],fp);    for(i=0;str2[i]!='\0';i++)        fputc(str2[i],fp);    fclose(fp);    printf("It's ok!");    getch();}


原创粉丝点击