vs读取.txt文件内容

//vs读取.txt文件内容,首先确定.txt文件的位置,

string filename =“//.txt”

//打开文件

ifstream camfile(filename, ios::in);

//判断是否为非空

if (!camfile)

//取.txt中的第一行内容

string s;

string newFilename;
while (getline(camfile, s))

//以上三句将.txt中的第一行字符串赋值给s,依次循环,取出所有的行字符串

//string 转  char[]

strcpy(c, s.c_str());

/从字符串最后取.后面的字符

char *ext = strrchr(c, '.');    //c 开始为 E:\\TEST\\tt.dat, 执行后 c 为E:\\TEST\\tt,  则 ext 为dat

//char[] 转string  

string = c ;   //直接赋值

 

你可能感兴趣的:(C++,图像基础知识)