Friday, 21 October 2011

Type of function in c++

Type of function in c++. String is a collection of several characters. Here are some of the functions contained in string operations:

     For Copying a String

         strcpy (string1, string2)
         : Copy the contents of kata1 to kata2.
     To Knowing Length of String

         strlen ()

         strlen (string);
         : For the declared mereturn integer length of the string.
     combining Strings

         strcat ();

         strcat
(string1, string2);
         : Attach a string 1 to string 2.
     Convert to uppercase

         strupr ()
     Convert to lowercase

         strlwr ()
         This function is the opposite of
         strupr ()
     Finding Substring

         strstr ()
         peggunaanya:
         strstr (string1, string2)
     String reverse

         strrev ()

That is some of the functions contained in string operations. Here I will give examples of their use.

Example of use:


/ / suppose there are 2 pieces of string for the experiment:
kata1 char [10] = "Exercise";
kata2 char [10] = "Try";

strupr (kata1); / / change kata1 to "EXERCISE"
court <

strlwr (kata2); / / change kata2 to "try"

strcat (kata1, kata2); / / merge the string becomes "Let's Exercise"

strstr (kata1, kata2); / / substring kata2 kata1 not, because the string "Practice" does not exist in the string "Try"

strrev (kata2); / / change the string "Try" to "aboC"

No comments:

Post a Comment