Partial string and character functions in the C language

Source: Internet
Author: User

////main.c//homeWork1230////#include<stdio.h>#include<string.h>#include<ctype.h>intMainintargcConst Char*argv[]) {///The/strstr (STR1,STR2) function is used to determine whether a string str2 is a substring of str1. If it is, the function returns the address that str2 first appears in str1, or null if it is not. //printf ("%s\n", Strstr ("Chinaisgood", "is"));            ////strcmp Compare string sizes based on ASCII. //printf ("%d\n", Strcoll ("Chinaisgood", "as"));            /*function Description: strcspn () computes consecutive characters from the beginning of the argument s string, and these characters are not in the string that the parameter reject refers to. In short, if the value returned by STRCSPN () is n, then the string s starts with a continuous n Characters in the string reject are not included in each character.*/ //printf ("%lu\n", strcspn ("Chinais good", "in")); //one is to find the position of a character in a string, and the other is to find the position of a string in another string, strstr. //printf ("%s\n", STRCHR ("abcdefghijklmnopqrstuvwxyz", ' C ')); //Copy//Char *b;//b=strdup ("AFNKSF");//printf ("%s\n", b); //S1,s2 is a string when memcmp (s1,s2,1) is the first byte of the comparison S1 and S2 ASCII code value;//printf ("%d\n", memcmp ("AVC", "DDS", 1)); //used to find the C string needle in the C string haystack, ignoring the case. A char pointer that returns the position of the first occurrence of the needle string in the haystack string if found//printf ("%s\n", Strcasestr ("Ffdsafds", "D")); //you can see what this is all about, this function, which is not implemented in most of the OS .//strnstr function Description, find S2 in the first pos1 string of S1, if present, return S2 in S1 position, if not found, return NULL, Test no problem//printf ("%s\n", Strnstr ("ABCD", "C", 2)); //Copy//Char *s= "Golden Global View";//Char d[20];//    //   //clrscr ();//    //stpcpy (d,s);//printf ("%s\n", D); //copy, only to Nth//Char *s= "Golden Global View";//Char d[20];//strlcpy (d, S, 6);//printf ("%s\n", D); //character Functions//determines whether the character variable C is a letter or a number, or returns a nonzero if it returns 0//printf ("%d\n", Isalnum (' $ ')); //used to determine if a character is a tab or a space, or nonzero if it returns 0//printf ("%d\n", Isblank (')); //function: Determine if character C is a control character//Note: When C is between 0x00-0x1f or equal to 0x7f (DEL), it returns a value other than 0, otherwise zero is returned. //printf ("%d\n", Iscntrl (' \ n ')); //determine if it is a printable character//printf ("%d\n", Isgraph (' $ ')); //Judging if it's a punctuation mark//printf ("%d\n", ispunct (' a ')); //Check if parameter C is a space character, that is, to determine whether it is a space ('), a horizontal position character//(' \ t '), return key (' \ R '), newline (' \ n '), vertical position character (' \v '), or page turn (' \f ')//printf ("%d\n", Isspace (' a ')); //to turn a character into an ASCII value//printf ("%d\n", Toascii (' a ')); //converts a character's number to an integral type//printf ("%d\n", Digittoint (' 9 ')); //determines whether a character is a number//printf ("%d\n", Isnumber (' 4 ')); //determines whether a character is between 0 and 127, whether it is ASCII//printf ("%d\n", Isascii (' n '));                return 0;}

Partial string and character functions in the C language

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.