Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 200
  • Last Modified:

write function

i'm having trouble getting data to write into my structure. i hope somebody could help asap.  below is my code and i thought i'm using the function right.  please help.
/**********CODE STARTS HERE************/
0
zandyl
Asked:
zandyl
  • 2
  • 2
1 Solution
 
kellyjjCommented:
could you please be a little clearer.  A quick look over doesn't show anything blantly wrong.
0
 
zandylAuthor Commented:
hi kellyjj,
i know, that is my problem.  it doesn't look like i'm doing anything wrong, but when i try to add a new record, it gives me the error"WRITE ERROR APPEND", w/c means it didn't write the record yet it looked like it wrote it.  Then when i try to retrieve the same record to modify if so it will write the time in the next time slot in the structure, it looks like it doesn't read the flag (tmptr) and it give me an error again when i write it back!!  i'm really stuck and i have no idea why??  please help.
thanks a bunch.
zandyl
0
 
kellyjjCommented:
ok,  I looked at the man pages on fopen.   for your flag try

"r+"  this flag is for updating and allows both reading and writing, although you will be responsible for where this happens.  When you use a+  when ever you write the write will always be done at the end of your file.  Looking at your code it looks like you are trying to set the pos and then write.  

I hope this helps
0
 
zandylAuthor Commented:
hi kellyjj,
i already tried that even before you got to answer me back.  i thought it was also my problem, i changed my fopen with an 'r+' and still it didn't work.  was my problem is where my pos=ftell(fp) line in code.  i tried several places and nothing helps. any other ideas?
thanks.
zandyl
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now