|
运行C++时总出现错误 ,请问是什么问题
程序名:
test1.C
代码如下:
#include <stdio.h>
void my_print(char *string);
void my_print2(char *string);
main()
{
char my_string[]=”Hello embedded Linux world”;
my_print(my_string);
my_print2(my_string);
}
void my_print(char *string)
{
printf(“The string is &s\n”,string);
}
void my_print2(char *string)
{
char *string2;
int size,i;
size=strlen(string);
string2=(char *)malloc(size+1);
for(i=0;i<size;i++) {
string2[size-i]=string;
}
string2[size+1]=’\0’;
printf(“The string printed backward is %s\n”,string2);
}
运行命令:
# g++ -o test1 test1.C
错误如下:
test1.C: In function `int main()':
test1.C:8: stray '\241' in program
test1.C:8: stray '\261' in program
test1.C:8: `Hello' undeclared (first use this function)
test1.C:8: (Each undeclared identifier is reported only once for each function
it appears in.)
test1.C:8: parse error before `Linux'
test1.C:8: stray '\241' in program
test1.C:8: stray '\261' in program
test1.C: In function `void my_print(char*)':
test1.C:16: stray '\241' in program
test1.C:16: stray '\260' in program
test1.C:16: parse error before `is'
test1.C:16: stray '\' in program
test1.C:16: stray '\241' in program
test1.C:16: stray '\261' in program
test1.C: In function `void my_print2(char*)':
test1.C:24: `strlen' undeclared (first use this function)
test1.C:25: `malloc' undeclared (first use this function)
test1.C:29: stray '\241' in program
test1.C:29: stray '\257' in program
test1.C:29: stray '\' in program
test1.C:29: stray '\241' in program
test1.C:29: stray '\257' in program
test1.C:30: stray '\241' in program
test1.C:30: stray '\260' in program
test1.C:30: parse error before `printed'
test1.C:30: stray '\' in program
test1.C:30: stray '\241' in program
test1.C:30: stray '\261' in program
You have new mail in /var/spool/mail/root |
|