Adding to an array in an external file, and adding elements to it.

Excuse my ignorance, but how would I do that?

FILE *fp=fopen("file.txt", "r");

Is what i'm thinking.

That is a good start. also the fgets, et cetera in the example I showed. If you have more specific questions I have more specific answers.

I've been advised to create a "dynamic array" for what i'm trying to do... I have no idea how to do this.

Advised by whom? Is this homework / coursework? If not, please explain the nature / background of your task / project.

how to implement with a dynamic array shown in #5 post

To all members: Please, no further posts until the homework question has been satisfactorily answered.

Advised by a friend. Someone who won't help out, unfortunately. The background, and/or nature of my project, is, I want to create something I haven't yet seen in other terminal programs. Which is what i'm writing, a terminal program.

My post in #15 uses a dynamic array.

Thanks for that. But, i'm having problems getting the code to work. As it seems, now, it doesn't save the changes made to the array....

Thanks.

--- Post updated at 05:09 PM ---

Bleh. I'm an idiot. I don't claim to be the best C programmer out there..

Anyway, what needs to be done, is to get the dynamic array code working.

When I make a call to the dynamic array function, it doesn't appear to do anything, except print out the elements of the array.
I still have to recompile the source in order for a new element to be displayed. What exactly, am I doing wrong here?

Thanks.

Ok. I solved it. Finally. I looked at Coron886's code, and extrapolated what I needed from it into my project. Everything is working now. Thanks to everyone who participated.

2 Likes