我正在處理文件。我想把每一行都分開,並在空格後分開。 例如,如果一號線有:今天是星期一我希望能有今天,是,週一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 –