2010年2月17日星期三

A simple file copy program

int main(int argc, char* argv[]){
char copy;

FILE* fr=fopen(argv[1],"r");
FILE* fw=fopen(argv[2], "w");

while(fscanf(fr,"c%", &copy){
fprintf(fw,"c%", copy);
}
return 0;
}

2010年2月10日星期三

pointer to function and flush for input

double (*fptr)(char * , int)
fptr = foo;
C: a = (*fptr)(".....", 23)
C++: a fptr("......", 23)

after scanf............
fflush(stdio);
can clear all the unneed input!

2010年2月8日星期一

Integer Array

a[5][4][3][2][1]
the pointer for this array ..in step is.
*(a[5][4][3][2]+1)
*(*(a[5][4][3]+2)+1)
*(*(*(a[5][4]+3)+2)+1)
*(*(*(*(a[5]+4)+3)+2)+1)
*(*(*(*(*(a+5)+4)+3)+2)+1)