just "double" is 8 bytes
what's the difference between "int" and "long int" ? they are both 4 bytes and with the same rang
float = (int) float; //delete all float
set float in an area, ex. %6.2f float may round off : 12.3478 -> 12.35
"unsigned" is good to use, it makes double rang for positive number
%-3d close the left side, %03d full 0 on left, if it is %-03d, 0 no function
operater % need both operand are integer
if function() will give back a print -> void
if function() will give back a integer -> int
2-dim array can no define the first array, ex. array[ ][4] it's easy way to increase the new element in array.
number to function is transfer number, but array to function is transfer array address. Because of that, if the number changed in array in function, the number really changed in main(). If it's not in array, number will not be changed.
string last memory is stored \0 ,so char str[ ] = {'h','e','l','l','o','\0'} = char str[ ] = "hello"
use gets to input string.
example :
char name[15] ;
gets(name);
「&」:位址運算子;「*」:依址取值運算子。
each pointer is 4 bytes. regardless int, char, ...etc. (it stores address.)
if you want to change number in function, you can't use pass by value, you must use pass by address.
a[i] = *(a+i)
int *ptr = a;
ptr+1 = a[1]
char str[ ] = char *ptr
a[ ] -> a = &a = &a[0]
int *max(int *);
int main(void)
{
int a[ ];
ptr = max(a);
}
int *max(int *array)
{
}
char str[3][10] -> char *ptr[3] it can reduce space wasted.
*(*num+m)+n) the value of array[m][n] num[0][0] = **num
if use scanf() , when you complete the value, you will type Enter. Enter will store in the buffer. You need to use fflush(stdin); clean the data in the buffer.
留言列表