[ create a new paste ] login | about

Link: http://codepad.org/YqBtvTcT    [ raw code | output | fork ]

C, pasted on Jul 1:
#include <stdio.h>
#include <string.h>

char * compress(char * text, const char * delims);

int main()
{
	char text[] = "This  - is  an   example, of text; ";
	printf("Input : %s\n", text);
	printf("Output: %s\n",  compress(text, " ,.;!?"));
	getchar();
	return 0;
}

char * compress(char * text, const char * delims)
{
	char * tok = strtok(text, delims);
	while( tok )
	{
		tok = strtok(NULL, delims);
		if( tok )
			sprintf(text, "%s%s",text, tok);
	}
	return text;
}


Output:
1
2
Input : This  - is  an   example, of text; 
Output: This-isanexampleoftext


Create a new paste based on this one


Comments: