使用fseek的问题 [英] Problem using fseek

查看:72
本文介绍了使用fseek的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好......


我的代码出了问题,当我这样说时:


recsize = sizeof (p1);

fseek(fp,-recsize,SEEK_CUR); fwrite(& p1,sizeof(p1),1,fp);

getch();


文件保存时的值正确且有些windows信息

呢!?


喜欢这个 8? ?我想知道我是谁。 E x e l& ? P $ / $
roduct N am e


有什么问题?!


Kisses

Hello everyone...

I′ve a problem with my code, when i put this lines:

recsize = sizeof(p1);
fseek(fp,-recsize,SEEK_CUR); fwrite(&p1,sizeof(p1),1,fp);
getch();

The file was saved with correct values and with some windows informations
too!?

like this " 8   O r i g i n a l F i l e n a m e C m d . E x e l &  P
r o d u c t N a m e"

what are the problem?!

Kisses

推荐答案

2月6日下午2:50,Maria Mela < h ... @ netvisao.ptwrote:
On Feb 6, 2:50 pm, "Maria Mela" <h...@netvisao.ptwrote:

大家好......


我有问题我的代码,当我把这句话:


recsize = sizeof(p1);

fseek(fp,-recsize,SEEK_CUR); fwrite(& p1,sizeof(p1),1,fp);

getch();


文件保存时的值正确且有些windows信息

呢!?


喜欢这个 8 O r i g i n a F i l e m m C m d。 E x e l& P

r o d t t N a m e


有什么问题?!
Hello everyone...

I′ve a problem with my code, when i put this lines:

recsize = sizeof(p1);
fseek(fp,-recsize,SEEK_CUR); fwrite(&p1,sizeof(p1),1,fp);
getch();

The file was saved with correct values and with some windows informations
too!?

like this " 8 O r i g i n a l F i l e n a m e C m d . E x e l & P
r o d u c t N a m e"

what are the problem?!



显示您正在使用的实际代码,而不是它的片段。

简化代码,直到您拥有最小的完整工作代码为止

演示了这个问题。


作为一个疯狂的猜测,你可能会尝试使用fread读取OLE复合文件

,这注定要幽默。

Show the actual code you are using and not a snippet of it.
Simplify the code until you have the minimal fully working code that
demonstrates the problem.

As a wild guess, you might be trying to read an OLE compound document
using fread, which is destined to humor.


user923005写道:
user923005 wrote:

2月6日,2:下午50点,Maria Mela < h ... @ netvisao.ptwrote:
On Feb 6, 2:50 pm, "Maria Mela" <h...@netvisao.ptwrote:

>大家好......

我的代码有问题,当我把这句话:

recsize = sizeof(p1);
fseek(fp,-recsize,SEEK_CUR); fwrite(& p1,sizeof(p1),1,fp);
getch();

文件保存了正确的值和一些窗口信息
!这样的

8 O r i g i n a F i l e m m C m d。 E x e l& P
你好吗?

有什么问题?!
>Hello everyone...

I′ve a problem with my code, when i put this lines:

recsize = sizeof(p1);
fseek(fp,-recsize,SEEK_CUR); fwrite(&p1,sizeof(p1),1,fp);
getch();

The file was saved with correct values and with some windows informations
too!?

like this " 8 O r i g i n a l F i l e n a m e C m d . E x e l & P
r o d u c t N a m e"

what are the problem?!



显示您正在使用的实际代码,而不是它的片段。

简化代码,直到您拥有最小的完整工作代码为止

演示了这个问题。


作为一个疯狂的猜测,你可能会尝试使用fread读取OLE复合文件

,这注定要幽默。


Show the actual code you are using and not a snippet of it.
Simplify the code until you have the minimal fully working code that
demonstrates the problem.

As a wild guess, you might be trying to read an OLE compound document
using fread, which is destined to humor.



或p1指向一个带指针的结构... fwrite()显然不会

序列化结构中的字符串指针。


也可能是字节填充?谁知道。

or p1 points to a struct with pointers... fwrite() obviously won''t
serialise string pointers in a struct.

maybe also byte padding? who knows.


这里是我的结构

struct customer {

int dd,mm ,yy;

char cus_ac_no [15],cus_name [25],cus_add [45],cus_ph_no [17];

double cus_bal;

float cus_intrst;

} p1;


typedef struct customer cust;


FILE * fp,* ft ;

int recsize;

char choice,any,ch,eno [23];

double dep,

void transac()// Transaccoes de um Cartao

{

int k,p,t,r;

system(" cls" ;);

k =有效();

倒带(fp);

if(k!= 2)

{

// _setcursortype(_NOCURSOR);

calbox(); highvideo();

gotoxy(12,12); cprintf(N£mero invalido!);

gotoxy(19,14); cprintf(" Tente Novamente);

getch();

}

其他

{

while(fread(& p1,sizeof(p1),1,fp)== 1)

{

if(strcmp(p1。 cus_ac_no,eno)== 0)

{

calbox();

fflush(stdin);

choice = getchar();

开关(选择)

{

/ * ------------- ---------------------------------------- * /

case''1'':

calbox();

gotoxy(5,5); cprintf(" xxxxxx:");

gotoxy(8,7); cprintf(" Euros:");

scanf("%lf" ,& dep);

p1.cus_bal + = dep;

acc_info(& p1);

recsize = sizeof(p1);

fseek(fp,-recsize,SEEK_CUR); fwrite(& p1,sizeof(p1),1,fp);

getch();

break;

" user923005" < dc ***** @ connx.comescreveu na mensagem

news:11 ********************** @ v45g2000cwv。 googlegr oups.com ...

2月6日下午2:50,Maria Mela < h ... @ netvisao.ptwrote:
here′s my struct

struct customer {
int dd,mm,yy;
char cus_ac_no[15],cus_name[25],cus_add[45],cus_ph_no[17];
double cus_bal;
float cus_intrst;
}p1;

typedef struct customer cust;

FILE *fp,*ft;
int recsize;
char choice,any,ch,eno[23];
double dep,
void transac()//Transaccoes de um Cartao
{
int k,p,t,r;
system("cls");
k=valid();
rewind(fp);
if(k!=2)
{
// _setcursortype(_NOCURSOR);
calbox(); highvideo();
gotoxy(12,12); cprintf(" N£mero invalido! ");
gotoxy(19,14); cprintf(" Tente Novamente");
getch();
}
else
{
while(fread(&p1,sizeof(p1),1,fp)==1)
{
if(strcmp(p1.cus_ac_no,eno)==0)
{
calbox();
fflush(stdin);
choice=getchar();
switch(choice)
{
/*-----------------------------------------------------*/
case ''1'':
calbox();
gotoxy(5,5); cprintf("xxxxxx:");
gotoxy(8,7);cprintf("Euros :");
scanf("%lf",&dep);
p1.cus_bal+=dep;
acc_info(&p1);
recsize = sizeof(p1);
fseek(fp,-recsize,SEEK_CUR); fwrite(&p1,sizeof(p1),1,fp);
getch();
break;
"user923005" <dc*****@connx.comescreveu na mensagem
news:11**********************@v45g2000cwv.googlegr oups.com...
On Feb 6, 2:50 pm, "Maria Mela" <h...@netvisao.ptwrote:

大家好......


我有问题我的代码,当我把这句话:


recsize = sizeof(p1);

fseek(fp,-recsize,SEEK_CUR); fwrite(& p1,sizeof(p1),1,fp);

getch();


文件保存时的值正确且有些windows信息

呢!?


喜欢这个 8 O r i g i n a F i l e m m C m d。 E x e l&

P

r o d t t N a m e


有什么问题?!
Hello everyone...

I′ve a problem with my code, when i put this lines:

recsize = sizeof(p1);
fseek(fp,-recsize,SEEK_CUR); fwrite(&p1,sizeof(p1),1,fp);
getch();

The file was saved with correct values and with some windows informations
too!?

like this " 8 O r i g i n a l F i l e n a m e C m d . E x e l &
P
r o d u c t N a m e"

what are the problem?!



显示您正在使用的实际代码,而不是它的片段。

简化代码,直到您拥有最小的完整工作代码为止

演示了这个问题。


作为一个疯狂的猜测,你可能会尝试使用fread读取OLE复合文件

,这注定要幽默。

Show the actual code you are using and not a snippet of it.
Simplify the code until you have the minimal fully working code that
demonstrates the problem.

As a wild guess, you might be trying to read an OLE compound document
using fread, which is destined to humor.


这篇关于使用fseek的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆