Saturday 19 March 2016

SMS Language


SMS language or textese (also known as txt-speak, txtese, chatspeak, txt, txtspk, txtk, txto, texting language, txt lingo, SMSish, txtslang,or txt talk) is a term for the abbreviations and slang commonly used with mobile phone text messaging. 

 Some of the abbreviations used are

  • s for yes
  • u for you
  • 2day for today
  • y for why

Many grandpa's have started sending SMSes to their grand children. But they are not familiar with the SMS lingo. 

Can you help them by writing a program that would convert a given text in proper English to SMS lingo? Consider only the 4 words listed above. 

Input Format: 
Input consists of a single string. Assume that the maximum length of the string is 200 and all letters are in lower-case. 

Output Format: 
Output consists of a single string. 

Sample Input 1: 
where were you yesterday? 

Sample Output 1: 
where were u yesterday? 

Sample Input 2: 
why is today a working day for you? 

Sample Output 2: 
y is 2day a working day for u?

Code:
  #include<stdio.h>
#include<string.h>
void replace(char *);
int main(){
  char s1[100];
  gets (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);
    }
}

34 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Compilation Errors -
    Main.c:25:7: warning: implicit declaration of function ‘sprint’ [-Wimplicit-function-declaration]
    /tmp/ccSSmlXK.o: In function `replace':
    Main.c:(.text+0x255): undefined reference to `sprint'
    collect2: ld returned 1 exit status

    error occured while compiling..plss help me out...thanks in advance :)

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
  3. This comment has been removed by the author.

    ReplyDelete
  4. warning: ‘ch’ may be used uninitialized in this function

    ReplyDelete
  5. My program has no compilation errors but only the first word of the statement is printed as output...!!!

    ReplyDelete
    Replies
    1. Probably in sprintf statement it's ch+strlen(r[i]) and not rep(i).

      Delete
  6. warning:'ch'maybe uninitialized in this function

    ReplyDelete
  7. Replace the 'void' of the function replace to char *
    (2 places)

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. Check may be uninitialized is howing

      Delete
  8. "ch" may be used uninitialized in this function

    ReplyDelete
  9. Great post! I am see the great contents and step by step read really nice information.I am gather this concepts and more information. It's helpful for me my friend. Also great blog here with all of the valuable information you have.
    R Language Training in Chennai

    ReplyDelete
  10. This comment has been removed by the author.

    ReplyDelete
  11. Appreciation for really being thoughtful and also for deciding on certain marvelous guides most people really want to be aware of.
    amazon-web-services-training-in-bangalore

    big-data-hadoop-training-institute-in-bangalore

    ReplyDelete
  12. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
    Click here:
    angularjs training in bangalore

    ReplyDelete
  13. Awesome..You have clearly explained …Its very useful for me to know about new things..Keep on blogging..
    Click here:
    Microsoft Azure training in online

    ReplyDelete
  14. This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to development very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.
    Data Science Training in Chennai
    Data science training in bangalore
    Data science online training
    Data science training in pune
    Data Science training in kalyan nagar
    Data Science training in OMR
    selenium training in chennai

    ReplyDelete
  15. Thank you for taking the time and sharing this information with us. It was indeed very helpful and insightful while being straight forward and to the point.
    German Classes in Chennai
    Java Training in Chennai
    German Courses in Chennai
    best german classes in chennai
    Java Coaching Center in Chennai
    Best Java Training in Chennai

    ReplyDelete
  16. Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. R Programming institutes in Chennai | R Programming Training in Chennai | R Programming Course Fees

    ReplyDelete
  17. Great blog..Well explained,it was really informative and useful.Thanks for sharing..keep update hadoop training in chennai velachery | hadoop training course fees in chennai | Hadoop Training in Chennai Omr

    ReplyDelete
  18. Its a good post and keep posting good article.its very interesting to read.
    R Programming Training Institute in Chennai

    ReplyDelete