+ 1
Is there any other way to extract words from a string other than the loop method in c?
2 Respuestas
+ 5
See this example
#include <stdio.h>
#include<string.h>
int main(void) {
char str[]=" templates and vectors";
char *token=strtok(str," ");
while(token!=NULL)
{
printf("%s\n",token);
token=strtok(NULL," ");
}
return 0;
}
+ 3
You can search for some functions related to strings on google.
Check out the split function!
In C,
the split function is called strtok()