文章标签Monologue
Monologue on Programming
07个月前
1.声明变量尽量在函数开头
#include <stdio.h>
#include <string.h>
char name[]=”mygogou”;
int main()
{
char output[8];
strcpy(output, name);
for(int i=0;i<8&&name[i];i++)
printf(“\\0x%x”,name[i]);
return 0;
}
写在.c文件中会编译报错。
Compiling… tmsg.c E:\as\vc-code\1\tmsg.c(8) : error C2143: syntax error : missing ‘;’ before ‘type’
经查证这是因为c和c++关于变量声明的一点点不同:
(更多…)