
#include <stdio.h>
#include <string.h>

const char delim[] = " \n";

void split(char *line)
{
	char *state = line;
	char *token;

	token = strtok_r(line, delim, &state);

	while (token != NULL)
	{
		printf("token: %s\n", token);
		token = strtok_r(NULL, delim, &state);
	}
}

int main(void)
{
	char line[1024];

	while (1)
	{
		if (feof(stdin) || ferror(stdin))
			break;

		if (fgets(line, sizeof(line), stdin) == NULL)
			break;

		split(line);
	}

	return 0;
}

