Line 87: Line 87:
 
strstr,
 
strstr,
 
strcat
 
strcat
 +
 +
 +
===================
 +
 +
Kevin Tan(0023987592), section#2 notes 04/05
 +
 +
random access
 +
 +
arr[5]; arr[9];
 +
 +
FILE *fp= NULL; fp = fopen(filename,"rb");
 +
 +
int a; double b; fread(&a,sizeof(int),1,fp); fread(&b,sizeof(double),1,fp); . . fscanf(fp,"%d%d",&a,&b);

Revision as of 11:10, 8 April 2012

Lecture 23 _4/5_Kailu Song

Review for exam 2,students could ask question 1.read file FILE *fptr;

fptr = fopen(filename,"rb");

int a;

double b;

fread(&a,sizeof(int),1,fptr);

fread(&b,sizeof(double),1,fptr);

Person P;

fread(&P,sizeof(Person),1,fptr);

int arr[10];

fread(arr,sizeof(int),10,fptr);

int ch;

ch = fgetc(fptr);

char = oneline[256];

fets(oneline,256,fptr);

(stop at '\n', or reach the limit'\o');

int a,b;

fscanf(fptr,"%d %d", &a,&b);

strlen not include '\o';

strcpy,strstr,strcat;

2.linklist with n nodes sorted,insert one more value

3, three outcomes:1.file;2.structure;3.dynamic structure(linked list);


========================================

Shiyu Wang Lec23 April 8th

Review for Exam2

randon access

arr[5]

arr[29]


FILE* fptr; fptr = fopen(filename,"rb");

                   (binary)

int a;

double b;

fread(&a,sizeof(int),1 fptr);

fread(&b,sizeof(double),1,fptr);

int ch;

ch=fgetc(fptr);

char oneline[256];

fgets(oneline,256,fptr);


(it will stop at'\n' or reach the limit'\0')

How to use strcpy, strstr, strcat


=======

Kevin Tan(0023987592), section#2 notes 04/05

random access

arr[5]; arr[9];

FILE *fp= NULL; fp = fopen(filename,"rb");

int a; double b; fread(&a,sizeof(int),1,fp); fread(&b,sizeof(double),1,fp); . . fscanf(fp,"%d%d",&a,&b);

Alumni Liaison

Ph.D. 2007, working on developing cool imaging technologies for digital cameras, camera phones, and video surveillance cameras.

Buyue Zhang