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

int main()
{
	char *buffer;
	size_t bufsize = 32;
	size_t characters;

	buffer = (char *)malloc(bufsize * sizeof(char));
	if( buffer == NULL)
	{
		perror("Unable to allocate buffer");
		exit(1);
	}

	printf("Type something: ");
	characters = getline(&buffer,&bufsize,stdin);
	printf("%zu characters were read.\n",characters);
	printf("You typed: %s",buffer);


	char *end_str,*token2;
	char *token = strtok_r(buffer,";",&end_str);
		printf("token : %s \n", token);
	int count =0,wordcnt=0;
	while(token !=NULL)
	{
		char *end_token;
		count++;
		printf("outside count ------------------------%d\n", count);
		strtok_r(token," ",&end_token);
		while(token2!=NULL)
		{
			wordcnt++;
			printf("insdie count %d\n",wordcnt);
			printf("%s------------------- \n", token2);
			token2 = strtok_r(NULL," ",&end_token);
		}
		token = strtok_r(NULL, ";",&end_str);
	}

	return(0);
}