How to write an array to a file in c

Remember Me? Thread: How to save array to file. How to save array to file. There is a simple C-code, where I defined array of string type.

How to save array to file

I know that I did something wrong in 'fwrite'. Please help me to find the problem and fix it. If the pointers are 8 bytes each, you are writing the first 13 bytes of the pointer values.

how to write an array to a file in c

If they are 4 byte pointers then you are writing all 8 bytes of the two pointers plus 5 bytes of whatever happens to be directly after them in memory.

You are not writing the strings at all unless you have 4-byte pointers and part of the strings are in those 5 extra bytes.

how to write an array to a file in c

Normally you don't use fwrite to write to a text file. After midnight begins the intoxication of pernicious truths. Originally Posted by john. Originally Posted by Bjarne Stroustrup I get maybe two dozen requests for help with some sort of programming or design problem every day.

C File Examples

Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves.

how to write an array to a file in c

Don't do this: Code:. Originally Posted by laserlight.

Your Answer

Replies: 5 Last Post:AM. By zmhnak in forum C Programming. Replies: 0 Last Post:PM. Replies: 1 Last Post:AM. By Blackroot in forum Windows Programming. Replies: 0 Last Post:AM. Save array By eletron in forum C Programming. Replies: 3 Last Post:PM. All times are GMT The posted resumes now is PM. All rights reserved.]