我是 C 新手,我在互联网上找到了关于字符串和数组的教程,并尝试做这个程序。他们正在使用 Eclipse,而我正在使用 Visual Studio 2010 ...请帮助和解释。我遇到了这些问题:
error C2143: syntax error : missing ';' before 'type'
error C2143: syntax error : missing ';' before 'type'
error C2143: syntax error : missing ')' before 'type'
error C2143: syntax error : missing ';' before 'type'
error C2065: 'cp' : undeclared identifier
error C2100: illegal indirection
warning C4552: '!=' : operator has no effect; expected operator with side-effect
error C2059: syntax error : ')'
error C2065: 'cp' : undeclared identifier
error C2143: syntax error : missing ';' before '{'
error C2065: 'cp' : undeclared identifier
error C2100: illegal indirection
这是代码:
#include <stdio.h>
#include <conio.h>
int main(char argc, char**argv){
char s[] = "string";
printf("string is: %s\n", s);
for(char *cp = s; *cp !=0; ++cp) {
printf("char is %c\n", *cp);
}
getch();
}