China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-01 00:07
中国DOS联盟论坛 » DOS开发编程 & 发展交流 (开发室) » Reading and writing large dbf files in C View 1,687 Replies 4
Original Poster Posted 2010-01-21 11:11 ·  中国 广东 深圳 福田区 电信
初级用户
Credits 72
Posts 24
Joined 2006-11-02 10:44
19-year member
UID 69292
Gender Male
Status Offline
I'm reading records in a dbf line by line in C under DOS, and it freezes when the data file gets large.

fseek(fp, headlength, 0); /* Position the file pointer to the start of the first record */
for (recno = 1; recno <= recnumber; recno++)
{
fgets(str, reclength + 1, fp);
printf("%u, %s\n", recno, str);
}

Does anyone have any good methods to solve this?
Floor 2 Posted 2010-01-21 12:00 ·  中国 重庆 联通
新手上路
Credits 18
Posts 8
Joined 2007-04-17 03:07
19-year member
UID 85435
Gender Male
Status Offline
Can you find if there are any header files for DBF file operations?
Floor 3 Posted 2010-01-21 12:03 ·  中国 重庆 联通
新手上路
Credits 18
Posts 8
Joined 2007-04-17 03:07
19-year member
UID 85435
Gender Male
Status Offline
Please provide the specific Chinese content that needs to be translated so that I can carry out the translation according to the requirements.
Floor 4 Posted 2010-01-21 12:46 ·  中国 广东 深圳 福田区 电信
初级用户
Credits 72
Posts 24
Joined 2006-11-02 10:44
19-year member
UID 69292
Gender Male
Status Offline
Thanks everyone, the problem is found. It's that the space of str is too small and the data content exceeds it
Floor 5 Posted 2010-01-21 12:53 ·  中国 广东 深圳 电信
高级用户
★★
Credits 668
Posts 295
Joined 2005-07-26 00:00
21-year member
UID 41110
Gender Male
From 广东深圳
Status Offline
This is too easy to understand,
Your recno is of type unsigned int, and the record number recnumber is of type unsinged long, so no matter how much recno is incremented, it can only change within 0~65535u.

If recno is of type unsigned long, then printf("%u, %s\n",recno, str) should be changed to
printf("%lu, %s\n",recno, str);
Forum Jump: