Watch your types.
Going off of
dubydapreek's revision:
- Lines 7..11: Useless. Get rid of them. (You don't need to copy b to a before you copy b to a.)
- Lines 27..28: You should be allocating an array of (double *).
- Lines 31..32: You should be allocating an array of (double).
As a rule, when using malloc(), it should look something like:
type *foo = (type *)malloc( n *sizeof( type ) );
where "type" is whatever type you need it to be. In your case, "type" is first (double*) then it is (double).
Hope this helps.
Reputation Points: 1140
Solved Threads: 229
Postaholic
Offline 2,039 posts
since Oct 2007