Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Writing to file in c?

Options
  • 22-02-2005 4:13pm
    #1
    Closed Accounts Posts: 1,541 ✭✭✭


    Hello All,

    I am trying to write a [8][61] matrix in c to a file.
    FILE* fp;
    double warpedresult[NO_OF_COEFF][AVERAGE];
    fp = fopen("c0r0.warp", "w+b");        
    fwrite(warpedresult, 1, sizeof(warpedresult), fp );
    fclose(fp);
    


    warped result is filled with correct values in program. I want to write these values to a file.

    It is giving no errors but when I read in file in matlab I am getting rubbish!

    Anyone out there know why?

    Thanks.


Comments

  • Registered Users Posts: 1,366 ✭✭✭king_of_inismac


    k, I think the problem is with your use of fwrite. It seems your argument list is wrong:

    The argument list for fwrite is as follows:

    The first parameter of fwrite is a pointer to the variable that you want to write to the file. The second parameter is the size of the variable that must e written. The third parameter is the number of variables to be written. The fourth parameter is the file pointer of the file you want to write to.

    I think you have the second and third parameter mixed up.

    best of luck with it,

    Martin

    btw: is this a *nun's island* project by any chance? :D


  • Closed Accounts Posts: 1,541 ✭✭✭finnpark


    Cheers Martin,

    Got it working now.

    Yep a "nun's island" job ;) and its rag week :cool: .


Advertisement