View Single Post
Join Date: Jun 2008
Posts: 66
Reputation: ambarisha.kn is an unknown quantity at this point 
Solved Threads: 0
ambarisha.kn ambarisha.kn is offline Offline
Junior Poster in Training

Help: fwrite, I want to write forward pointer address in present file pointer

 
0
  #1
Oct 22nd, 2008
I wrote the following function and it is working fine, but my problem is i want to write forward pointer address in present pointer field.

I will explain in code.
please check line numbers 10, 11, 12, 13 in the following code..
  1. void create_fbeCodeDat()
  2. {
  3. int checkSum=0;
  4. fwrite(&signature,1, 4, bin_fp);//signature=0xabcd0001
  5. fwrite(&version, 1,4,bin_fp);//Version番号
  6. fseek(bin_fp,4,SEEK_CUR); //FBD Program code
  7. fseek(bin_fp,2,SEEK_CUR); //not used
  8. fwrite(&fbdStepno,1,2,bin_fp); //FBD step No.[N1]
  9. fseek(bin_fp,4,SEEK_CUR); //const data offset
  10. //Here i have to write the address of next fbdstepno*4+1 bytes
  11. //consider fbdstepno=4, here in 4 bytes have to write address of 5th byte address
  12. // for ex: next 5th byte adress has to be write here in 4 bytes
  13. //fwrite( addr(5th byte), 1,4, bin_fp); //how to write 1st argument
  14. // actually in the program here i have to write the address of buffList[buf].fbCodeAddr in 4 bytes. for buf=0, have to write bufflist[0].fbCodeAddr in 4 bytes
  15. // for buf=0 and 1, have to write bufflist[0].fbCodeAddr in 4 bytes, and bufflist[1].fbCodeAddr in 4 bytes
  16. //and so on... and next the following code continues..
  17.  
  18. for(int buf=0; buf<buffList.size();++buf)
  19. {
  20. fwrite(buffList[buf].fbCodeAddr,1,buffList[buf].tmpAddr+4-buffList[buf].fbCodeAddr, bin_fp);
  21. }
  22. fwrite(&checkSum,1,4,bin_fp);//sum値
  23. }
Last edited by ambarisha.kn; Oct 22nd, 2008 at 1:51 am.
Ambarish
Reply With Quote