标题:从键盘上输入一串字符,将其写入文件myfile.c中,之后将文件中内容输出在屏 ...
只看楼主
hehuihh2004
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2006-11-3
 问题点数:0 回复次数:0 
从键盘上输入一串字符,将其写入文件myfile.c中,之后将文件中内容输出在屏幕上给用
#include "stdio.h"
#include "string.h"
#define ERROR 0
#define n 6
main()
{
FILE *fp;
char chs[n];
char ch[n];
int i;
if ((fp=fopen("myfile.c","w"))==NULL)
{
printf("Can’t open the file ang press any key to exit\n");
getchar();
return ERROR;
}
printf("\nPlease input the string!\n");
scanf("%s",ch);
fputs(ch,fp);
fclose(fp);
getchar();
}
搜索更多相关主题的帖子: myfile 屏幕 字符 键盘 文件 
2006-11-04 20:00



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-100758-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014056 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved