I am working on a file. I want to take each line and split after the space.
For example if line1 has: today is monday I want to have today, is, monday separatly in order to work on them
Here is my code so far:
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 );
}
To tokenize a string you can use strtok()
Check the example in the link I post, just change the separator to space:
( code from the example linked )