The array name is also the address of the first element of the array: for example name=&name[0]
For string input, you can use an array to write
int main ()
{
Char name[40];
scanf ("%s", name);
printf ("%s", name);
}
#defineSIZE 4intMain () { ShortDatas[size]; Shortshort*PTI; Shortindex; DoubleBills[size]; Doubledouble*PTF; PTI=datas; PTF=bills; printf ("%23s%10s"," Short","double\n"); for(index=0; index<size;index++) printf ("pointers+%d:%10p%10p \ n", index, PTI+index,ptf+index); return 0; }
I've talked about short 2 bytes double 8 bytes
3d25-05c35-3=22-c=2-12 = (16+2-12) = 6 (because 2-12 is not enough to reduce, so the forward borrowing 1 is three) d-5= (13-1-5) = 7 (13-1 is because 2-12 is not enough to be borrowed a bit) 3-0=3 result is: 3762H
Here dates+2=&dates[2]; The same address
* (dates+2) ==dates[2]; The same value
*dates+2; This self-understanding, in fact, for the array, is not a pointer to the array, in fact, the array name and the pointer variable name, is equivalent, so here can use dates instead of PTI, code verification: Look at the online, the array name is actually a pointer, but there is a difference, the array name is the pointer constant, PTI PTF pointer is a pointer variable
As you can see, the int address is 4 bytes apart, and 4*8 is 32 bits. 12ff70-12ff6c= 4, so what is the pointer?
The pointer is to store the address 0x0012ff6c;
#include <stdio.h>intMain () {intI=5; int*Pi; Pi=&i; printf ("%d\n", i); printf ("%d\n",&i); printf ("%d\n", PI); }
So to declare the pointer variable, the value of this variable is the memory address of the storage variable I, equivalent to the house number.
Reproduced:
#include <stdio.h>
int main ()
{
Char I,*pi;
i=10;
pi=&i; Initialize it, you should
*pi=20;
printf ("%d", I);
Run Result: i=20
This means that the operation is done directly through the pointer. Changed the value of the variable i.
Arrays and pointers (i)