C language learning Day1 summary

  • There is one and only one main function in int main(). When using int main(), the last line in () is best to enter return 0;
    add at the end of each statement in
    () ; printf() outputs scanf(), such as Need to use this function, need to call the function, use #include<stdio.h>, scanf() after the comma, need to use the address symbol & (print() and input() in Python need to be distinguished)

  • char character data type 1
    short (int) short integer 2 or 4
    int integer 4
    long (int) long integer 4 or 8
    long long (int) longer integer 16
    float single precision floating point 4
    double double precision floating Point 8
    long double long double precision 16 The
    above unit is byte (1 byte = 8bits)
    eg: short age = 20;//Apply for two bytes = 16 Bit bits from the memory to store 20
  • //%c print data in character format
    //%d print integer decimal data
    //%f print floating-point numbers-decimals
    %p print in the form of addresses
    %x print hexadecimal numbers
    print single floating-point numbers use% f
    print double floating point number is best to use %lf
  • Global variables-variables defined outside the code block (())
    local variables-variables defined in the code block (())
  • C language grammar stipulates that variables should be defined at the top of the current code block
    eg(err): C language learning Day1 summary
    eg(right):C language learning Day1 summary

    1. Scope: The name used in general program code is not always valid/available,
      and the code scope that limits the availability of the name is the scope of the name. The scope of the
      local variable is the scope of the local variable where the variable is located. The scope of the
      global variable Is the whole project
  • define Defined identifier constant
    #define MAX 10
    const-constant attribute
    eg:const int n = 10
    n is a variable, but there are constant attributes, so we say n is a constant variable, generally speaking, the value of the variable after const definition unable to be changed.

  • Literal constants: 3, 100, etc.
  • Enumeration constant: enumeration-enumerate one by one
    eg: enum Sex
    {FEMALE
    MALE
    UNKNOWN}
    enum Sex a = FEMALE
    %d When outputting a, the result is 0 (in most programming languages, the index starts from 0)
  • String (string): '0' the end of the string, you can use the strlen() function to calculate the length of the string
  • Array: A collection
    that stores multiple variables. Definition: Data type array name [] = {}
    eg: int arr1[] = {1,2,3}. char arr2[] = {'a','b', 'c',0(\0,'\0')} char arr3[] = "abc"
    (Strings are generally stored in arrays.
    When "" appears when storing a string, it will be regarded as a string by default, and the end It will automatically add 0
    and mix with the characters of ``. When you need to output in string form, you need to manually add '0' or 0)
  • ASCII code: the keyboard corresponding to each number or character corresponding to a number (maximum of 128 decimal digits)
    common characters, numbers corresponding to ASCII code:
    '\ 0' - 0
    'A' - 97
    'A' - -65
  • Escape character \: For example, if you want to print a path c:\test\32\test.c\,
    direct printing is not possible. In C language, \t represents a horizontal tab character (ie 4 spaces) \32 represents an octal number 32 (Ie 26 in decimal) To make the path print out, you need to add a \ before \test and \32, so that the \ before t(32) loses the meaning of escape, that is, c:\test\32\test.c\ n. * \ddd represents three digits in octal ddd, \xdd represents two digits in hexadecimal and
    printing a single quotation mark (double quotation mark) can also be similarly used.
  • Three-letter words (unpopular): ?? Adding'(' or')' will become a corresponding character (it will have this effect in vc6.0)

Guess you like

Origin blog.51cto.com/14971119/2542825