(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 06: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

Abstract algebra continues the conceptual developments of linear algebra, on an even grander scale.

Dr. Paul Garrett