1. Get the address of the array no, because the array name itself is an address
#include int main(void) { char c = 'A'; char cs[] = "ABC"; printf("%c,%s\n",c,cs); /* 获取字符及字符数组的内容 */
1. Variable addresses can be obtained through & variables:
#include int main(void) { int num = 10; printf("变量值: %d\n",num); printf("变量址: %d\n",&num); getchar(); return 0; }
2. A variable that represents a variable address is a
1. The logo of the array is []:
#include int main(void) { int nums[3]; nums[0] = 11; nums[1] = 22; nums[2] = 33; printf("%d,%d,%d",nums[0],nums[1],nums[2]); getchar(); return 0; }
2. Size and dimensions of the array:
#include
1. The result of the operation exceeds the type size:
#include #include int main(void) { short s1 = SHRT_MAX; short s2 = SHRT_MAX; short num1; int num2; /* 不会是期望的值 */ num1 = s1 + s2; printf("%d\n",num1); /* 这样可以了 */ num2 = s1
曾经对float num=3.14f; 这样的赋值非常疑惑,其实现在也不明白. 既然说明了是float类型,又何必在3.14后面挂个f呢? 书上说: int num=100; 一个整数常量将默认为int类型(除非常数有后缀或超出了int的范围) double num=3.14; 一个浮点数常量将默认为double类型 并要求: long num=100L; long long num=100LL; unsigned long=100UL; unsigned long long num=100
The variable that gets the type size is best not the int type, but the size_t type;
size_t are defined in stdio.h and stddef.h.
1. Get the size of a known type:
#include #include int main (void){char n = 2;size_t size; size = sizeof
In the C language, the char type is always a byte, and the Double-byte character type is wchar_t;
But it is not a built-in type, defined in Stddef.h.
Assign a value to a character or character array (that is, a string) of type wchar_t to be
整型int可添加short和long: short int:简为short; long int: 简为long; long long int: 简为long long 它们都可以再添加 unsigned: unsigned int: 简为unsigned unsigned short int: 简为unsigned short unsigned long int: 简为unsigned long unsigned long long int: 简为unsigned long
C Language Data type: Basic type, constructed type, pointer type, empty type.
Basic types include: integer, character, floating-point (single, double), enumeration.
The constructed types also include: arrays, structs, and common bodies.
1.
1. General:
#include int main(void) { int i; for (i = 0; i switch (i) { case 1: printf("%d\n", i); break; case 3: printf("%d\n", i); break; case 5: printf("%d\n", i);
1. General:
#include int main(void) { int i; for (i=0;i if (i%2==0) printf("%d 是偶数\n", i); if (i%2!=0) printf("%d 是奇数\n", i); } getchar(); return 0; } #include int main(void) { int i; for (i = 0; i if (i > 4)
1. While loop:
#include int main(void) { int i=0; while (i i++; printf("%d\n", i); } getchar(); return 0; }
2. Do While loop:
#include int main(void) { int i=0; do { i++; printf("%d\n", i); } while (i
1. For the basic form of the loop:
#include int main(void) { int i; for (i=0;i printf("%d\n",i); } getchar(); return 0; }
2. Step Size:
#include int main(void) { int i; for (i=0;i printf("%d\n",i); } getchar();
3.if...elseif statement
The actual application often faces more choice, at this time, will If...else expands, then obtains the IF...ELSEIF structure, its general form is:
if
statement 1
else if
statement 2
else if
In the three basic structures of the program, the second is the choice of structure, its basic characteristics are: The process of the program is composed of multiple branches, in the process of executing a program, according to different
6.3.1 pointer operators and pointer expressions
There are two operators on pointers in C:
& Operator: Takes the address operator, &m is the address of the variable m.
* Operator: pointer operator, *PTR represents the variable to which it is
Because the function call of C program is called by value, that is, when the actual parameter is combined with the formal parameter, the real arguments value is passed to the formal parameter, so when we use the function to process the array, if we
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.