C Language Learning Diary 2

Source: Internet
Author: User
Tags array definition

Yesterday was a good night to return, and watched the video, en ... Sister is very beautiful.

1, goto statement (such as Goto Flag1; Flag1:), Identifiers and Goto in the same function, up and down do not matter.

2, "" is a string, ' is a single character.

3. Array: one-dimensional array data type array identifier [constant expression] Two-bit array data type array identifier [constant expression 1][constant expression 2] reference time identifier [constant], subscript starting at 0, array element Common reference number of constant expression

A[3][4] 3 Rows 4 columns

A[0][0] a[0][1] a[0][2] a[0][3]

A[1][0] a[1][1] a[1][2] a[1][3]

A[2][0] a[2][1] a[2][2] a[2][3]

When defining a two-dimensional array, assigning an initial value to all elements can omit row subscript but cannot omit column subscript (I think it is better not to save better, see also clear, it is best to add each line of curly braces, in case the error check up too annoying.

Mark: Mark here, I used to like the Rubik's Cube when I was a child, but when I was a child, I never had it, and I was too old to play it. Now I want to re-play, Rubik's Cube is a square, 6 sides 6 colors, according to 1-6 number is not can be regarded as 6 two-dimensional array? So is it possible to use a computer to help me figure out how to turn? Wait until I finish C and look back.

Mark:4, gets () seems to have changed? Although it can be used but is warned. Remember to check.

5, character, string correlation function: Single character output Putchar (char), single character input, input return is worth a variable, I=getchar (); String output puts ("Hello world!"); '/' is the end but I think no one is full enough to add this up. String input gets (i); Save in I, I is an array, i[].

A character array definition: a char identifier [constant expression], a constant that represents how much of your array gives him the character, the longest, and the subscript of the same dimensional array. The simplest way to define it: Char a[]= "Hello"; fully automatic last add ' n '.

Character array input/output: printf ("%c", A[i]);//single character output, printf ("%s", a);//string output, Input gets (a);//gets () will be appended to the string after each call So when you use the output string is always looking at the same as you input, in fact, just not show it.

String copy: strcpy (destination character array name, source character array name)

String Connection: strcat (destination character array name, source character array name)

string comparison: strcmp (character array name 1, character array name 2) Two string output 0, string 1> string 2 Returns a positive number, string 1< string 2 returns a negative number

String Case Conversion: STRUPR (String)//lowercase to uppercase, STRLWR (string)//capitalization to lowercase

Get string Length: strlen (String)//return value is length

              

C Language Learning Diary 2

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.