阅读:982回复:4
高分请教读取文件数据的问题!急!!!!
因为板子的要求,我每次只能从文件中读取16K的数据写到板子上去,如果我要从文件中读取的数据远大于16K,我只能多次调用从文件中读取数据的函数(PCI9054_WriteToRam1 ()),当我调用一次读取数据的函数读取一帧数据后,第二次调用时怎样使指针指到文件上第二帧数据的起始位?
下面是我的代码,PCI9054_ReadWriteBlock()是写数据到板子上的函数。 void PCI9054_WriteToRam1 (PCI9054_HANDLE hPCI9054, PCI9054_ADDR addrSpace, DWORD dwOffset, WORD data) { FILE *fp; short a[16383]; UINT i; if((fp=fopen("F:\\data\\adsin.dat","r"))==NULL) { printf("cannot open file\n"); exit(0); } for(i=0;i<=16382;i++) { //while(!feof(fp)) fscanf(fp, "%d", &a); } fclose(fp); dwOffset=2; for(i=0; i<=16382;i++) { data=a; PCI9054_ReadWriteBlock(hPCI9054, addrSpace, dwOffset, FALSE, &data, sizeof(WORD), PCI9054_MODE_WORD); dwOffset+=2; } } |
|
最新喜欢:yjx200... |
沙发#
发布于:2004-09-03 11:41
用FREAD,系统会自动修改文件指针的。。。。。。
|
|
|
板凳#
发布于:2004-09-03 15:14
用FREAD,第二次调用PCI9054_WriteToRam1()时指针还是指在文件的起始地址吧,会指在第二帧数据的起始地址吗?
|
|
地板#
发布于:2004-09-03 17:28
int fread (void * buffer, size_t size, size_t count, FILE * stream);
Read block of data from a stream. Read count number of items each one with a size of size bytes from the stream and stores it in the specified buffer. Stream's postion indicator is increased by the number of bytes readed. Total amount of bytes read is (size x count). |
|
|
地下室#
发布于:2004-09-03 18:38
用以下这个函数可以将指针移到指定位置:
int fseek( FILE *stream, long offset, int origin ); |
|