Is there any other way to extract words from a string other than the loop method in c? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Is there any other way to extract words from a string other than the loop method in c?

25th Aug 2020, 5:06 AM
Dikki
Dikki - avatar
2 Answers
+ 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; }
25th Aug 2020, 7:53 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 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()
25th Aug 2020, 5:26 AM
Namit Jain
Namit Jain - avatar