Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,266 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,510 people online right now. Registration is fast and FREE... Join Now!




Fwrite strange behavior

 
Reply to this topicStart new topic

Fwrite strange behavior, to work or not to work???

sissy0584
7 Nov, 2006 - 03:25 AM
Post #1

New D.I.C Head
*

Joined: 2 Nov, 2006
Posts: 9


My Contributions
Hi guys,

something strange (well strange to me...but maybe there is an easy explaination...) happens using the fwrite.

That is to say that used after a fread() works, if i use with an array allocated in memory, it doesn't... why does this happen? is it normal? how to solve it?

Take a look:
CODE

c_pn = fread(pn,sizeof(float),239,f_primary);
c_pw = fwrite(pn,sizeof(float),239,f_out);


like this it works perfectly;

CODE


for(i=0;i<100;i++)
    d[i]= i;
    
c_dw = fwrite(d,sizeof(float),100,f_out);


with this it doesn't work.....

both the arrays, d and pn, are allocated with malloc().

Any clue??

Thx a lot.

Silvia

User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/4/08 07:28PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month