要求从.txt文件中按行读取数据,
例如:one line;first
two line;second
;NULL
注:“;”后面是注释
此时从这个.txt文件中按行读取到的数据应为 one line
two line
请按照上述要求写出对应的C++程序
例如:one line;first
two line;second
;NULL
注:“;”后面是注释
此时从这个.txt文件中按行读取到的数据应为 one line
two line
请按照上述要求写出对应的C++程序
char buff[1024];
int count;for(int i = 0; i < 3; i++)
{
count = sscanf(data[i], "%[^;]", buff);
if(count == 1)
{
cout << "'" << buff << "'" << endl;
}
}