C 学习笔记
Perfect Code Can Say Anything
-----------------------------------------------------------------------------------------------------------------
eg1:
int array[10]={9} array=9 0 0 0 0 0 0 0 0 0
int array[0]={0} array=0 0 0 0 0 0 0 0 0 0
++array[0] => get the array[0] number and increase. and result array[0] value is 1
----------------------------------------------------------------------------------------------------------------
eg2.
//count the number's times
int c=0
int array[10];
while((c=getchar())!=EOF){
if(c>='0'&&c<='9')
{
++array[c-'0'] ;
}
}
"hello\n" --------->h e l l o \n \0
-----------------------------------------------------------------------------------------------
eg3
int getline(char s[],lim)
for(i=0;i<lim-1&&(c=getchar())!=EOF&&c!='\n';i++)
{s[i]=c;}
if(c=='\n') s[i]=c
-----------------------------------------------------------------------------
void copy(char to[] ,char from[])
{
int i=0;
while((to[i]=from[i])!='\0'){
i++;
}
}
---------------------------------------------------------------------------------
int *pa
int a[10]
a[1] is diffreent from a ====>a[1] is a int number and a is a pointer
a is a pointer so pa=a equal pa=&a[0] and a[i] equal *(a+i)
a[0] equal *pa ====>a[i] equal pa[i]
char *s equal char s[]
-------------------------------------------------------------------------------------
char amessage[]="Hello C" can be modified it's an array
char *amessage="Hello C" can't be modified string const