SMS Language In C

In this tutorial, we will learn how to convert plain English text message into SMS Language In C Programming language.

What is SMS Language?

SMS Language is also known as slang used in mobile phones that are trendy these days.

SMS Language(Abbreviation) English word
s yes
u you
2day today
y why

The above table showcases some of the common abbreviations that are used.

Example

why is today a holiday for you?

Sample Output:

y is 2day a holiday for u?

Now let’s have a look on C program to convert the above plain text into slang word(SMS Language).

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

void replacefunction(char *s1)//function to replace the text into slang
{
    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);
        }
    
}
int main()
{
    char s1[100];
    gets(s1);
    replacefunction(s1);//calling function
    printf("\n%s",s1); //printing the SMS Language oriented text
    return 0;
}

The above C program was just a sample code of some of the abbreviation conversion, You can try your hands by adding more abbreviation and have fun with the code.

Do you want to Master in C Programming?

Leave a Reply