Dave's Brain

Browse - programming tips - strtok r example

Date: 2010mar15

Q.  How do I use strtok_r() ?

A.  Here's an example.  This function uses strtok_r() to break up a string
they is delimited by semi-colons and commas.

	void BreakOnPunct(char *s)
	{
		const char *	delim = ";,";
		char *		save;
		char *		p;

		for (p = strtok_r(s, delim, &save); p; p = strtok_r(NULL, delim, &save))
		{
			printf("chunk=%s\n", *p);
		}
	}
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2012, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Advertisements: