how to break the 1d character array into small arrays

I have a file in which i have data stored in the form of

file1.txt
file2.txt
file3.txt
file4.txt
file5.txt

I have put this information into a 1d array from the file using stream insertion operator like this

ifstream in;
in.open("names.txt");
char array[45];
for(int i=0; i<45; i++)
{
in>>array[i];

}

now my question is how can i split this 1d array into the parts as file1.txt, file2.txt, and so on???? plz help i will be so thankful to u people..
There are a number of ways you can do it. It all depends on how you want it stored. personally I would store them in a 2d array instead of 1d. so it would be like
char array[5][45];
so char [0][x] would hold the data from file 1 char[1][x] would hold for file 2 and so on. It shouldn't be too hard for you to do and you can have it assign to the proper part of the array when its reading in so you wont have to break it up after.
Last edited on
closed account (zb0S216C)
Maybe indicate the end of each section with the null-terminating character? For example, the first X bytes are for 1 file. The next byte is a null-character which indicates the end-of-section. After that, another X byte section for another file.

Why not use multiple arrays? Or even a 2-D array?

Wazzak
i have done it with a 2D array .. thank u so much both of u ...
Topic archived. No new replies allowed.