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)

2010年1月29日星期五

OOP WEEK 3 Challenge....

void bio_putint(int val){
int i;
int x;
int temp[99];
int length;
for (i = 1, length = 0; val / i != 0 ; i *= 10, length++);
for(i = length,x = 0 ; i >0; temp[x]=(val/(10^(i-1))%10+48), i--, x++);
bio_putch(temp);
}

2010年1月27日星期三

Third Week OOP NOTE

Pointer: it alway have the same size
P = &i;
i+= 10\
-same
*p+=10/

ASS(1):there is a new folder create in the trunk called PRJ that have all the code for the assignment 1 (going to be)

Define statment: equal to search and replace before compliation

2010年1月21日星期四

Second Week OOP NOTE

SVN:->
1.Before commit need to everyone confirm.
2.The code in the trunk must in the compliate state.
3.All the command can taget to a specific file.
4.Example for check out in matrix: svn co svn://zenit.senecac.on.ca/oop344
5.only the the file end with .vcproj and code file

C:->
LOOP function:
for(i=0; i<10; i++);{
print("%d", a[i]);
}

for (i=0; i>10; printf("%d",a[i++]));

swith(___){
case V1;
break;
case V2;
break;
case V3;
break;
}

(%u -> unsign integer)

RAM:
it is a template place to store value
&i -> address of i.

2010年1月13日星期三

OOP344 Witer First Week NOTE

SVN://zenit.senecac.on.ca/oop344

CHECK OUT = Get
Commit = Put

OOP NOTE:
i++ ; //integer add one after
++i; //integer add one before

Too main type of variable: Float and Integer
Integer-> Float->
Char:1 Double: Mid
Int:? Float: Low
Short:2 Long double: high
Long:4
Long Long:8