读取字符串字符时出错
Error reading the character of a string
#include <algorithm>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "kcftracker.hpp"
#include <dirent.h>
using namespace std;
using namespace cv;
int main(int argc, char* argv[]){
if (argc > 5) return -1;
bool HOG = true;
bool FIXEDWINDOW = false;
bool MULTISCALE = true;
bool SILENT = true;
bool LAB = false;
for(int i = 0; i < argc; i++){
if ( strcmp (argv[i], "hog") == 0 )
HOG = true;
if ( strcmp (argv[i], "fixed_window") == 0 )
FIXEDWINDOW = true;
if ( strcmp (argv[i], "singlescale") == 0 )
MULTISCALE = false;
if ( strcmp (argv[i], "show") == 0 )
SILENT = false;
if ( strcmp (argv[i], "lab") == 0 ){
LAB = true;
HOG = true;
}
if ( strcmp (argv[i], "gray") == 0 )
HOG = false;
}
// Create KCFTracker object
KCFTracker tracker(HOG, FIXEDWINDOW, MULTISCALE, LAB);
// Frame readed
Mat frame;
// Tracker results
Rect result;
// Path to list.txt
ifstream listFile;
string fileName = "C:\UsersPeterLinDocumentsVisual Studio 2015ProjectsProject7x64Debugballimages.txt";
listFile.open(fileName);
每次我运行此代码时,系统都会告诉我读取字符串时出错,无法获取文件名。我想知道原因。
您没有正确转义 \。
如果逃避它们太痛苦了,它们通常可以,您可以尝试使用逐字字符串文字。 用作前缀,它要求编译器忽略转义字符。编写正则表达式时非常有用。
在这里阅读: http://stroustrup.com/C++11FAQ.html#raw-strings
相关文章:
- 分段 使用 MPI_Gather 收集字符数组时出错
- 将常量字符* 转换为字符时出错
- 读取字符串C++的字符时出错
- 为什么常量字符*到常量字符转换出错?
- 读取字符串字符时出错 - 对于数组中的字符串值
- 通过字符串::插入插入字符时出错
- 读取字符串字符时出错
- 计算字符串中字符的出现次数时出错
- C++ 使用 Strtok 读取字符串字符时出错
- C++:使用 fgets() 读取字符输入时出错
- C ++ ifstream 无法读取字符串,并且在读取字符时出错
- 尝试将常量字符 [] static_cast<>为无符号字符 * 时出错
- 从字符串中读取字符时出错
- 英特尔 TBB,parallel_pipeline,当我在阶段之间传递常量字符*时出错
- 转换(常量字符*)变量出错
- 为什么我从字符转换为字符时出错
- 读取字符串C++的字符时出错
- wcscpy_s后读取字符串字符时出错
- 读取字符串 的字符时出错.分配内存
- 读取字符串的字符时出错-访问冲突错误C++