C Language _ correlation function and structure body

Source: Internet
Author: User
Tags uppercase letter

string-related functions

Know

#include<ctype.h>

1. int isalpha (int c);

Determines whether a character is a letter.

2. int isnumber (int c);

Determines whether a character is a character that represents a number.

3. int isupper (int c);

Determines whether a character is a character that represents an uppercase letter

4. int islower (int c);

Determines whether a character is a lowercase letter.

5. int toupper(int c);

Converts a character to uppercase.

6. int tolower (int c);

Converts a character to a lowercase letter.

Master

#include <string.h>

7. size_t strlen (const char * s);

Passes in a string that returns the number of valid characters for the string.

Hello world!

Size_t is the alias of unsigned long.

Strlen is a function that evaluates the number of valid characters in a string

sizeof is an operator that evaluates the length of a variable or data type

8. Char * strcpy (char * s1, const char * s2);

Copies the string s2 to the character array S1, returning S1, the address of the first element of the character array.

Use this function as long as the S1 has enough space. If out of bounds, an unknown error may be caused.

9.int strcmp (const char * s1, const char * s2);

Compare the size relationships of two strings

The S1 returns a positive number, S2 returns a negative number, and returns 0 for equal size.

char * strcat (char * s1, const char * s2);

S1 is an array of characters, and S2 is a string or an array of characters.

S2 The contents of the S1 to form a new string, a new string, stored in S1.

The return value is S1.

11.char * STRSTR (const char *S1, const char *S2);

In the string S1, look for the position where the substring S2 first appeared.

Returns the address of the first character in the S1 where the substring first appears in a string.

S1 = Asdgjjuteeww

S2 = Tee

12.char *STRCHR (const char *s,char c);

Finds the position of the first occurrence of the character C in the string S.

Returns a pointer to the position of the first occurrence of C, which is the first pointer to the same character as Val at the beginning of the lookup string pointer, and returns NULL if there is no C in S.

13.char *STRRCHR (Char *str, char c);

Finds the last occurrence of a specified character in a string

If successful, returns all characters from that position to the end of the string, or null if it fails

<stdlib.h>

14.int atoi (const char * s);

Pass in a string representing a number, returning the number represented by the string

"1234"

================================

Structural body

struct: A set of variables that have the same or different data types.

Array: A set of variables that have the same data type.

struct student

{

int A;

Short B;

char c;

};

struct initialization

struct assignment

struct-Body pointer

struct aliases

struct array

C Language _ correlation function and structure body

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.