编程题:将字符串写入文件noobdream.txt
N诺智能批改可自动批改答案并给出反馈,每次使用将消耗 1个诺币
您当前的诺币数量: 个
N诺正在智能批改,预计需要30秒,请稍候...
int main() { FILE* pf = fopen("no.txt","w"); if (pf==NULL) { perror("fpoen"); return 1; } fputs("nishidashabi",pf); fclose(pf); free(pf); return 0; }
int main() { FILE* pf = fopen("noobdream.txt","w"); //判断文件指针是否为空 if (pf==NULL) { perror("fopen"); return 1; } //写文件 fputs("大碗宽面\n",pf); //关闭文件 fclose(pf); pf = NULL; return 0; }
#include <stdio.h> #include <string.h> int main() { //将字符串写入文件noobdream.txt char str[100]; fgets(str,sizeof(str),stdin); FILE *fd; fd=fopen("noobdream.txt","wb"); if(fd==NULL) { printf("don't find"); return 0; } fputs(str,fd); printf("write success"); return 0; }
#include<stdio.h>
int main(){
FILE *f;
char s[10];
scanf("%s",&s);
f=fopen("noobdream.txt","w");
if(fp==NULL) return 1;
fputs(s,f);
fclose(f);
return 0;}
#include "stdio.h"
#define a 100
void main()
{
char ch[a];
scanf("请输入字符串:%s",&ch);
FILE *files;
files=fopen(".\noobdream.txt","w+");
fputs(ch,files);
fclose(files);
}
#include <stdio.h> #include<stdlib.h> #include <stdbool.h> #include <string.h> int main() { FILE *fp=NULL; fp=fopen("大学课程/lx.txt","w+"); fputs("hello i am Grace",fp); fclose(fp); return 0; }
#include <stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> #define N 100 int main(void) { FILE* fp; char string[N];
fp = fopen("D:\\OneDrive\\桌面\\noobdream.txt", "w"); if (fp == NULL) { puts("ERROR"); exit(1); } printf("输入字符串:\n"); fgets(string, N - 1, stdin); fprintf(fp, "%s", string); printf("字符串已成功写入文件noobdream.txt\n"); fclose(fp); return 0;
#include<stdio.h> #define N 1000 int main { char source[N]={0}; FILE *fp; fp = fopen ("noobdream.txt","wb"); if( fp == NULL ){ printf("创建文失败"); return -1; } gets(source); fprintf(fp,"%s",source); fclose(fp) return -1;
int main() { char source[1024]={0}; FILE * fp=fopen("noobdream.txt","w"); gets(source); fprintf(fp,"%s",source);
if(fp!=NULL) { fclose(fp);
fp=NULL; }
return 0; }
#include <stdio.h>
int main() { char str[20]; scanf("%s",str); FILE *fp; fp=fopen("D:\\noobdream.txt","w"); fputs(str,fp); fclose(fp); return 0; }
#include <stdi...
登录后提交答案