我正在处理文件。我想把每一行都分开,并在空格后分开。 例如,如果一号线有:今天是星期一我希望能有今天,是,周一separatly为了对他们的工作将文本添加到行尾
这是到目前为止我的代码:
FILE *file = fopen ("file1", "r");
if ((file != NULL))
{
char line [ 128 ];
while((fgets (line, sizeof line, file) != NULL))
{
//tokenize the line based on space
??
}
how to add text at the end of the line? i mean i have **today is monday** and i want to add for example **Yupppy** at the end of today is monday line.
fclose (file);
}
你可以使用strtok – Vijay
可以请你发表一个例子吗?thx –
我还需要在每行的结尾添加一个新的工作。你可以帮我吗?thx –