hi all,
thanks for reading my post. sorry about the tittle (so whatever ;))
i have this situation. i have an array like this:
lemon
banana
pineapple

and i have fruit.txt which has this inside:
corn
melon
berry
blackcurrent
apple

what i want to do is, i want to copy the list in array to the fruit.txt but,the list must be top of the list in file like this:
lemon
banana
pineapple
corn
melon
berry
blackcurrent
apple

anyone has an idea about the code?since this is not work for this situation

char seed_array[100][100]="lemon","banana","pineapple";
int row=5;
for(int count=0;count<=row;count++)
        {
          
                  fprintf (fruit_file,"\n%s",seed_array[count]);
         
        }

Write the data to a temporary file and rename it as fruit.txt

Read the file, add the file fruit to the list, output the list back to the file.
Open
Read in loop
Close
Open
Write in loop
Close

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.