Some common functions about strings in C language, C language strings

Source: Internet
Author: User

Some common functions about strings in C language, C language strings

Add string. h to the header file when using the following:

Getch () is the asc code that is returned when you type any value but is not displayed. The compilation is completed immediately.
Getchar (); after you press enter, the input is complete. You can use putchar () to display the first character. The return value is the asc code.
Puts () Outputs a string (only one) to the terminal, which can contain escape characters.
Gets (); enter a string from the terminal to the character array and obtain a function value. The function value is the starting address of the character array.
Strcat (str1, str2); string catenate string connection function, concatenates string 2 to string 1
Strcpy (character array 1, string 2 (can be an array or a String constant); // you cannot assign a string to an array directly or assign an array to another array, values can only be assigned using the strcpy () function.
Strncpy (character array, string 2, n); string copy indicates replacing the first n digits of the character array with the first n digits of the character array.
Strcmp (string 1, string 2); string compare compares whether two strings are the same. If they are equal, the return value is 0. If they are not equal, the result of comparing different first digits is used as a reference. If String 1> string 2 is used, the return value is positive. Otherwise, the return value is negative.
Strlen (); returns the string length function string length
Strlwr (); English string lowercase; function for converting uppercase letters into lowercase letters
Strupr (); string uppercase; converts lowercase letters of a string to uppercase.

Related Article

Contact Us

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.