QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 964|回复: 2

一个简单的编译问题,请各位帮看下

[复制链接]
发表于 2006-3-2 10:14:03 | 显示全部楼层 |阅读模式
运行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
发表于 2006-3-2 12:30:40 | 显示全部楼层
兄弟, 你的"是全角的.
回复

使用道具 举报

 楼主| 发表于 2006-3-2 13:05:53 | 显示全部楼层
大哥
谢谢你
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-2 22:26 , Processed in 0.040351 second(s), 16 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表