Basic operation of Character array

Source: Internet
Author: User
Tags strcmp

#include <stdio.h>
#include <string.h>

void Main () {

/**
Char ch[]= "China\nbeijin";
Char ca= ' a ';

Char c[12];
Gets (c);

Puts (CH);
Puts (c);
*/

Char ch1[30]={"China Beijing"};
Char ch2[]={"Caoyangqu"};
Char ch3[30];
Character array connection, CH2 connected to CH1
strcat (CH1,CH2)

printf ("%s\n", strcat (CH1,CH2));

Copy of character array, CH1 copy to CH3
strcpy (CH3,CH1);
strcpy (CH3,CH1);
printf ("%s\n", CH3);

A comparison of character arrays. Ch1>ch2, returns a positive number; CH1&LT;CH2, returns a negative number; Ch1=ch2, returns zero
strcmp (CH1,CH2)
printf ("%d\n", strcmp (CH1,CH2));

The length of the character array
Strlen (CH1)
printf ("%d\n", strlen (CH1));

The character array becomes lowercase
STRLWR (CH2)
The character array becomes uppercase
STRUPR (CH2)

printf ("%s\n", STRLWR (CH2));
printf ("%s\n", Strupr (CH2));
}

Basic operation of Character array

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.