# Basic C Language Algorithm 39-string classic operation, algorithm 39 string

Source: Internet
Author: User

Basic C Language Algorithm 39-string classic operation, algorithm 39 string
// String concept!
/*
========================================================== ======================================
Question: Exercise string
1. Input and Output gets (str) puts (str)
2. Length statistics strlen (str)
3. case-sensitive conversion strupr (str) strlwr (str)
4. Compare strcmp (str1, str2)
5. Connect strcat (str1, str2)
6. Copy strcpy (str1, str2)
7. Reverse strrev (str)
========================================================== ======================================
*/
# Include <stdio. h>
# Include <string. h>
# Define gekai printf ("\ n ================================ ===============================\ n ")
Void main ()
{
Char s [256], t [256];
Printf ("string s :");
Gets (s );
Printf ("string t :");
Gets (t );
Gekai;
Printf ("\ n string s: \ n % s \ n", s );
Printf ("Length: % d \ n", strlen (s ));
Gekai;
Printf ("\ n string t is \ n % s \ n", t );
Printf ("Length: % d \ n", strlen (t ));
Gekai;
Printf ("\ n to uppercase: \ n ");
Printf ("string s :");
Puts (strupr (s ));
Printf ("string t :");
Puts (strupr (t ));
Gekai;
Printf ("\ n ");
Gekai;
Printf ("\ n to lowercase: \ n ");
Printf ("string s :");
Puts (strlwr (s ));
Printf ("string t :");
Puts (strlwr (t ));
Gekai;
Printf ("\ n ");
Gekai;
Printf ("\ n compare size :");
If (strcmp (s, t) = 1)
Printf ("string s is greater than string t! \ N ");
Else
Printf ("string s is smaller than string t! \ N ");
Gekai;
Printf ("\ n ");
Gekai;
Printf ("\ n connects two strings: \ n ");
Puts (strcat (s, t ));
Gekai;
Printf ("\ n ");
Gekai;
Printf ("\ n Copy string t to string s: \ n ");
Puts (strcpy (s, t ));
Gekai;
Printf ("\ n ");
Gekai;
Printf ("\ n reverse two strings: \ n ");
Puts (strrev (s ));
Puts (strrev (t ));
Gekai;
Printf ("\ n ");
}

/*
========================================================== ======================================
Comments: it is no problem to master the concept syntax.
========================================================== ======================================
*/

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.