SMS Language

QUESTION

SMS language or text ese (also known as txt speak, txtese, chat speak, txt, txt spk, txt k, tx to, texting language, txt lingo, SMSish, txts lang, ortx ttalk) is a term for the abbreviations and slang commonly used with mobile phone text messaging.\n\nSomeoftheabbreviationsusedare\n1\tsforyes\n2\tuforyou\n3\t2dayfortoday\n4\tyforwhy\n\nMany grand pa have started sending SMSes to their grand children. But they are not familiar with the SMSlingo.\n\nCanyouhelpthembywritingaprogramthatwouldconvertagiventextinproperEnglishtoSMSlingo?\n\nConsideronlythe4wordslistedabove.\n\nInputFormat:\nInputconsistsofasinglestring.Assumethatthemaximumlengthofthestringis200andalllettersareinlower-case.\n\nOutputFormat:\nOutputconsistsofasinglestring.

“TESTCASE_1”: “where were you yesterday\n###—###SEPERATOR—###—\nwhere were u sterday”, “TESTCASE_2”: “why is today a working day for you\n###—###SEPERATOR—###—\ny is 2day a working day for u”, “TESTCASE_3”: “eLab and eVerify is for you and opened today\n###—###SEPERATOR—###—\neLab and eVerify is for u and opened 2day”, “TESTCASE_4”: “0\n###—###SEPERATOR—###—\n0”, “TESTCASE_5”: “0\n###—###SEPERATOR—###—\n0

ANSWER

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

void replace(char *);

int main()
{
	char s1[200];
	
   scanf("%[^\n]%*c", s1);
	replace(s1);
	printf("\n%s",s1);
	return 0;
}

void replace(char *s1)
{
	char r[4][10]={"yes","you","today","why"};
	char rep[4][5]={"s","u","2day","y"};
	char buff[500];
	int i;
	char *ch;
	for(i=0;i<4;i++)
	{
		if((ch=strstr(s1,r[i])))
		{
			strncpy(buff,s1,ch-s1);
			buff[ch-s1]=0;
			sprintf(buff+(ch-s1),"%s%s",rep[i],ch+strlen(r[i]));
			s1[0]=0;
			strcpy(s1,buff);
			return replace(s1);
		}
	}
}
Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.