The first day of learning C

It's not a document or a tutorial. It's just supervising myself to learn C language by clocking in and recording only some small notes. If there is any mistake, thank you very much for pointing it out! ! !

One, clion shortcut keys

  • Format code ctrl+alt+L
  • Bring up the search ctrl+shift+A
  • Code style suggestion alt+enter
  • Single line comment ctrl+/
  • Multi-line comment ctrl+shift+/

Two, clion font and code style

  • Font: setting->Editor->Font
  • Code style setting: setting->Code Style->C/C+±> upper right corner set from
  • Use uppercase for functions and lowercase for variables

Three, int data type

Formatting symbols:

  • d is an integer
  • u unsigned integer
  • ll long integer
  • hd means short integer
  • s is a string
  • x is hexadecimal
  • oct is octal
  • Using the limits.h file, you can print out the maximum range and minimum range of a certain type such as INT_MAX, INT_MIN, etc.
  • The number of bytes occupied by the data type is different on different systems

Four, char data type

  • Char is actually a number internally, mapped from the ASCII table
  • When assigning a character variable to a character, you can assign the character directly, or / followed by an octal or hexadecimal number, and the corresponding value is converted to the corresponding decimal, and then compared to the ASCII table. For example,'\61' and'\x31' both represent 49, and 49 in the ASCII table is "1", so'\61' is '1'.
  • \n:newline
  • \b:backspace
  • \r:return
  • \t:table
  • ':' character literal
  • ":" string literal
  • The ASCII character set is American and is suitable for English. Char is a byte, while Chinese corresponds to Unicode. Instead of using char, use wchar_t (wide character) added after c95. In smvc, it is actually one Unsigned short integer, occupying 2 bytes. (Add an L before the literal amount)
  • But when using utf-8 encoding, it is not a character, but a byte.
  • Use %d to print out the number of'中', which is the code point (Code Point) corresponding to Unicode
  • When wide character escapes hexadecimal not the beginning of'\x', but the code point of'\u' plus unicode.

Five, floating-point data type

  • Float is single-precision. The c standard does not specify how many bytes it occupies (4 bytes in my MSVC environment). Instead, it specifies that it can represent at least 6 significant digits, ranging from -10 -37 to 10 37.
  • double is double precision (8 bytes in MSVC)
  • Floating-point data argument without f defaults to double precision
  • Floating point data is expressed as 1.2345*e^4 using scientific notation 12345
  • Float is 4 bytes, then it is 32 bits, take out 8 bits to represent the exponent (exponent of science and technology method e), 23 bits to represent the number of digits (the number after the decimal point), and the number before the decimal point is called the hidden place.

Six, constants

  • The const definition is called a read-only variable. After a pointer points to it, you can still modify it! ! !
  • Macros defined by #define will be preprocessed during compilation.
  • Corresponding to undef, cancel macro
  • True constants are independent variables!

Seven, mess

  • MSVC does not support standards after C90
  • Windows often uses JBK encoding. In today's study, I clearly typed the; symbol in English, but an error was reported that it could not be found. The reason is that our file uses UTF-8 encoding, and MSVC is JBK, so we need to transfer the file Encoding method.

Guess you like

Origin blog.csdn.net/qq_45549336/article/details/112690980