error: stray ‘\×××’ in program错误原因及解决方法

网上down了一个C++的程序,内容很简单,但g++编译时报错,报错内容如下

 error: stray ‘\342’ in program
   VideoCapture cap(”nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)1280, 
   ^
tx2opencv.cpp:9:3: error: stray ‘\200’ in program
tx2opencv.cpp:9:3: error: stray ‘\235’ in program
tx2opencv.cpp:9:3: error: stray ‘\342’ in program
tx2opencv.cpp:9:3: error: stray ‘\200’ in program
tx2opencv.cpp:9:3: error: stray ‘\235’ in program
tx2opencv.cpp:13:7: error: stray ‘\342’ in program
       cout << ”Failed to open camera.” << endl;  
       ^
tx2opencv.cpp:13:7: error: stray ‘\200’ in program
tx2opencv.cpp:13:7: error: stray ‘\235’ in program
tx2opencv.cpp:13:7: error: stray ‘\342’ in program
tx2opencv.cpp:13:7: error: stray ‘\200’ in program
tx2opencv.cpp:13:7: error: stray ‘\235’ in program
tx2opencv.cpp:21:7: error: stray ‘\342’ in program
       imshow(”original”, frame);  
       ^
tx2opencv.cpp:21:7: error: stray ‘\200’ in program
tx2opencv.cpp:21:7: error: stray ‘\235’ in program
tx2opencv.cpp:21:7: error: stray ‘\342’ in program
tx2opencv.cpp:21:7: error: stray ‘\200’ in program
tx2opencv.cpp:21:7: error: stray ‘\235’ in program

网上查了一下原因,是因为代码中有中文字符,比如双引号/分号等是中文格式的,因此将代码中的标点全部替换了一遍,确保为英文字符,然后重新编译,顺利通过!

相关推荐
©️2020 CSDN 皮肤主题: 游动-白 设计师:白松林 返回首页