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);