下面关于输入txt 文件时该注意什么?
#include<stdio.h>#include<stdlib.h>
#include<string.h>
#define null 0
void main()
{main:
int n;
printf("商品售出系统-----------1\n");
printf("修改商品目录-----------2\n");
printf("进入");scanf("%d",&n);printf("\n");
switch(n)
{case(1):
{printf("售出系统:\n");
FILE *fp; char a[1000];
memset(a,0,sizeof(a));
if((fp=fopen("d:\\sort.txt","a+"))==null)
printf("there is not opened! ");
fread(a,30,50,fp);
printf("%s\n",a);
fclose(fp);
}
case(2):
{FILE *fp; char a[1000],b[1000];
memset(a,0,sizeof(a));
if((fp=fopen("d:\\sort.txt","a+"))==null)
printf("there is not opened! ");
fread(a,30,50,fp);
printf("%s\n",a);
printf("你想加入的商品内容是(格式 名称价格/kg):");//这里有个问题。我输入怎么实现换行?求高手指点。。
memset(b,0,sizeof(b));
scanf("%s",&b);
fputs(b,fp);
fclose(fp);
goto main;
}
default: printf("输入错误!");
}
}