[法式设想]会C 的同志帮我阐发是怎么回事

3个月前 (11-25 19:19)阅读4回复0
wly
wly
  • 管理员
  • 注册排名8
  • 经验值131815
  • 级别管理员
  • 主题26363
  • 回复0
楼主

#include stdio.h

  main()

  {file *fp;

  char ch,filename[10];

  scanf("%s",filename);

  if ((fp=fopen(filename,"w"))==null)

  {printf("can not open\n");

  exit(0);}

  ch=getchar();

  ch=getchar();

  while(ch!='#')

   fputc(ch,fp);putchar(ch);

   ch=getchar();

  fclose(fp);

  汇编时,一点的法式没想到那么多错误

  Compiling...

  nihao.c

  f:\nihao.c(3) : error C2065: 'file' : undeclared identifier

  f:\nihao.c(3) : error C2065: 'fp' : undeclared identifier

  f:\nihao.c(3) : warning C4552: '*' : operator has no effect; expected operator with side-effect

  f:\nihao.c(4) : error C2143: syntax error : missing ';' before 'type'

  f:\nihao.c(5) : error C2065: 'filename' : undeclared identifier

  f:\nihao.c(6) : warning C4047: 'function' : 'const char *' differs in levels of indirection from 'int '

  f:\nihao.c(6) : warning C4024: 'fopen' : different types for formal and actual parameter 1

  f:\nihao.c(6) : warning C4047: '=' : 'int ' differs in levels of indirection from 'struct _iobuf *'

  f:\nihao.c(6) : error C2065: 'null' : undeclared identifier

  f:\nihao.c(8) : warning C4013: 'exit' undefined; assuming extern returning int

  f:\nihao.c(9) : error C2065: 'ch' : undeclared identifier

  f:\nihao.c(13) : warning C4047: 'function' : 'struct _iobuf *' differs in levels of indirection from 'int '

  f:\nihao.c(13) : warning C4024: 'fputc' : different types for formal and actual parameter 2

  f:\nihao.c(16) : warning C4047: 'function' : 'struct _iobuf *' differs in levels of indirection from 'int '

  f:\nihao.c(16) : warning C4024: 'fclose' : different types for formal and actual parameter 1

  并且死机 了

0
回帖

[法式设想]会C 的同志帮我阐发是怎么回事 期待您的回复!

取消