All pastes #673174 Raw Edit

Unnamed

public c v1 · immutable
#673174 ·published 2007-08-28 06:05 UTC
rendered paste body
#include<stdio.h>#include<string.h>#define SIZE 500int main(){	char str[SIZE], word[10][100], temp[50], ch;	int i, j, len, spc = 0, ctr = 0, freq = 0;		printf("\nWelcome to String Properties\n");	printf("____________________________\n");		printf("Enter string: ");	scanf("%[^\n]", str);	/*	Properties begin here*/		len = strlen(str);		for(i = 0, j = 0; i <= len; i ++)	{		if(str[i] == ' ')		{			spc ++;			ctr = strlen(temp);			strcpy(word[j], temp);			word[j][ctr] = '\0';			j ++;			ctr = 0;		}		else		{			temp[ctr] = str[i];			ctr++;		}	}		strcpy(word[j], temp);;		printf("List of words:\n");	for(i = 0; i <= j; i ++)	{		printf("[%d] %s\n", i + 1, word[i]);	}		printf("\nLength: \t\t\t%3d", len);	printf("\nLength (non-whitespace): \t%3d", len - spc);	printf("\nSpaces: \t\t\t%3d", spc);		printf("\n\nYou are entering the frequency mode of strprop. To exit, type ~\n");	for(;;)	{		freq = 0;		scanf("%c", &ch);		scanf("%c", &ch);				if(ch == '~')		{			printf("Exiting gracefully .....");			break;		}		else		{			for(i = 0; i <= len; i ++)			{				if(str[i] == ch)					freq ++;			}			printf("Frequency: %d\n", freq);		}	}		printf("\n");	return 0;}