遇到的编程语法细节 备注 备忘

1、

sprintf(imgName,"material00%02d.jpg",i);

注意:  %02d  不能写成 %2d


2、

error: stray ‘\357’ in program

error: stray ‘\357’ in program

error: stray ‘\274’ in program

error: stray ‘\233’ in program

 

出现此类错误的原因,在编辑器中使用的utf-8的格式保存源代码中出现了中文的标点符号


3、ubuntu进行编译时,提示错误:

浮点数例外(核心已转储)

int print_GCD(int a,int b)
{
        while(a%b!=0){
                a=b;
                b=a%b;}
        return b;
}

这里,因为前面 a=b
所以下面的 b = a % b; 相当于 b = b % b; 这样就有 b = 0;
于是回去判断循环条件, a % 0 != 0
好了,0放在除数的位置,你的程序死了


4、报错:  错误 1 error C2664: “Display::Display(const Display &)”: 无法将参数 3 从“const char [21]”转换为“std::string &”

类声明:

public:
Display(int width,int height,std::string & title);

main.cpp 中类对象的创建:

Display display(800,600,"www.mengfanchang.com");

错误原因:

需要将类.h中的函数声明   和  类.cpp中的函数重载(实现)的第三个字符串函数修改为 const类型:

public:
Display(int width,int height,const std::string & title);







评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值