Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Writing to file in c?

  • 22-02-2005 04: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, Registered Users 2 Posts: 1,368 ✭✭✭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