(New page: 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,...)
 
Line 44: Line 44:
  
 
3, three outcomes:1.file;2.structure;3.dynamic structure(linked list);
 
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

Revision as of 05:59, 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

Alumni Liaison

Basic linear algebra uncovers and clarifies very important geometry and algebra.

Dr. Paul Garrett