Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,089 questions

40,776 answers

573 users

How to use the strtok() to split a string s[] into tokens in C

1 Answer

0 votes
#include <stdio.h>
#include <string.h>
 
int main(void)
{
	char s[] = "The C - programming, language.";
	char *p;
  
	p = strtok(s, " ,.-");
	while (p != NULL)
	{
		printf ("%s\n", p);
		p = strtok(NULL, " ,.-");
	}
     
    return 0;
}

 
/* 
run:

The
C
programming
language

*/

 





answered Feb 16, 2016 by avibootz

Related questions

2 answers 132 views
1 answer 28 views
28 views asked May 14, 2022 by avibootz
1 answer 21 views
1 answer 30 views
30 views asked May 14, 2023 by avibootz
...