File input into a second array

Hello,

Can someone please look at my code and show me how to add a output a second array on the side of the current array? The code uses File input to get information into the array.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include <fstream>

using namespace std;

int main()


{
    int array_size = 1024;
	char * array = new char[array_size];
	int position = 0;

            ifstream fin("userslist-game-c.txt");



    if(fin.is_open())
{

            cout << "File Opened successfully!!!. Reading data from file into array" << endl;

    while(!fin.eof() && position < array_size)
{
			fin.get(array[position]);
			position++;
}
            array[position-1] = '\0';

            cout << "Displaying Array..." << endl << endl;

    for(int i = 0; array[i] != '\0'; i++)
{
			cout << array[i];
}
}
	else
{
            cout << "File could not be opened." << endl;
}
return 0;
}
Last edited on
Topic archived. No new replies allowed.