char buf[1024];
char *in = "line one\n\nline two\r\nline three\nline four\r\nline five\r\n";
ULONG i = 0;
if (in[i] != '\0'){ //字符串不为空
while (true){
while (in[i] == '\r' || in[i] == '\n') i++; //跳过换行符
if (in[i] == '\0') break; //读取结束
if (1 == sscanf_s(in + i, "%1023[^\r\n]", buf, 1024)){
MessageBoxA(NULL, buf, "OK", NULL);
i += strlen(buf);
}
else break; //出错退出
}
}
C++ 使用 sscanf_s 读取字符串中的每一行
最新推荐文章于 2024-03-02 07:00:00 发布