String in C language Reviewed by Momizat on . String is a collection of a batch of characters including alphabets,space,symbols and special characters and digits. In C language there are a number of restric String is a collection of a batch of characters including alphabets,space,symbols and special characters and digits. In C language there are a number of restric Rating: 0

String in C language

String is a collection of a batch of characters including alphabets,space,symbols and special characters and digits.
In C language there are a number of restrictions for the string such as:-

  • String argument is not possible.
  • String copy is not possible.
  • String comparison is not possible.

To avoid problem of C language provides number of string function which are for list below

  • strcpy():- It is used to copy string to string.
    //syntax strcpy(string1,string2);
    s1="manish";
    s2="kumar";
    strcpy(s1,s2);
    //output s1="kumar";s2="kumar";
    
  • strcat():- It is used to concatenate/merges two strings.
    //syntax strcat(string1,string2);
    s1="manish";
    s2="kumar";
    strcat(s1,s2);
    //output s1="manish kumar";s2="kumar";
    
  • strcmp():- It is used to compare two strings and return integer value if the integer value zero it means both strings are same.
    //syntax strcmp(string1,string2);
    s1="kumar";
    s2="kumar";
    x=strcmp(s1,s2);
    //output x=0;
    
  • stricmp():- It is same strcmp function but it ignore the case of the string.
    //syntax stricmp(string1,string2);
    s1="Kumar";
    s2="kumar";
    x=stricmp(s1,s2);
    //output x=0;
    
  • strlen():- It’s return length of string.
    //syntax strlen(string);
    s1="Kumar";
    x=strlen(s1);
    //output x=5;
    
  • strlwr():- It’s used to convert into lower case.
    //syntax strlwr(string);
    s1="Kumar";
    strlwr(s1);
    //output kumar;
    
  • strupr():- It’s used to convert into upper case.
    //syntax strupr(string);
    s1="Kumar";
    strupr(s1);
    //output KUMAR;
    

Leave a Comment

© 2014 Powered By