How to use random read-write file method, taking the value assigned to the member list in C language.
struct LibraryManage
{
char StudentID[20];
char BookIndex[20];
char LoanBookTime[20];
};
the "LoanBook.txt" Content is as follows:
StudentID BookIndex LoanBookTime
20101001 C01 10/8/2010
20101002 CPP02 12/9/2010
thanks.

Sam HobbsPosted Mar 1, 2012, 4:11 AM
Programmers in the past often used fixed-length records. Younger programmers choke on the idea. It does get complicated in the C++ language due to classes.
I forget the details of what function is used to read data using C. I could look it up but so can you.
The main problem is that if you read 60 characters then the data will not have the zero byte at the eend of each string. You can use one of the functions in strncpy_s, _strncpy_s_l, wcsncpy_s, _wcsncpy_s_l, _mbsncpy_s, _mbsncpy_s_l to copy each string to another place where you can add a zero byte.
Other than that, can you specify what you need help with? What is it that you do not know how to do?
Ken HPosted Mar 1, 2012, 11:51 AM
Sam HobbsPosted Mar 1, 2012, 8:29 AM
Ken HPosted Mar 1, 2012, 8:04 AM
Ken HPosted Mar 1, 2012, 7:57 AM