更新时间:2023-12-03 21:22:28
您只需通过删除AY \\ r
或 \\ n缩短字符串
结尾,例如:人物变化:
You can just shorten the string by deleting ay \r
or \n
characters at the end, e.g. change:
...
strcpy(linec, line);
...
到
int len;
...
strcpy(linec, line);
len = strlen(linec); // get length of string
while (len > 0) // while string not empty
{ // if last char is \r or \n
if (linec[len - 1] == '\r' || linec[len - 1] == '\n')
{
linec[len - 1] = '\0'; // delete it
len--;
}
else // otherwise we found the last "real" character
break;
}
...
请注意,当你打印字符串,您将需要添加一个换行符,例如用
Note that when you print the string you will need to add a line feed, e.g. use
fprintf(write, "%s\n", linec);