Need some help this array code.

i can't seem to output the array i filled with random numbers into a file like notepad or mircosoft word. idk if what I'm doing is even correct.. pls help ;/


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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include<iostream>
#include<fstream>
#include<cstdlib>
#include<ctime>
#include<string>
using namespace std;
 
int RowTest();
int ColumnTest();
void ArrayFiller();
string GetFileName();
void PrintArray();
 
int main()
{
    int Row = RowTest();
    int Column = ColumnTest();
    int Array [50][50] ;
    int FilledArray = ArrayFiller();
    string FileName = GetFileName();
    srand ((time(NULL)));
             
     
    return(0);
     
}
 
int RowTest()
{
    int Row;
    
    do
    {
        cout << "Enter the number of rows you would like in the array, that is between 2 and 50 \n";
        cin >> Row;
    }
    while ( (Row < 2) || (Row > 50) );
     
    
    return (Row);
}
 
int ColumnTest()
{
    int Column;
    do
    {
        cout << "Please enter a value for the column of the array that is between 2 and 50.\n";
        cin >> Column;
    }
    while ( (Column < 2) || (Column > 50) );
 
    return (Column);
}
 
string GetFileName()
{
    string FileName;
     
    cout << " Please enter the name of the file \n";
    cin >> FileName;
     
    return(FileName);
}
 
 int ArrayFiller( int Array[50][50] , int Row , int Column )
 
{
    for ( int i = 0; i < Row; i++ )
        for ( int k = 0; k < Column; k++ )
        { 
            Array[i][k] = rand() % 100 ;
        }
    return(FilledArray);
}
 
void PrintArray( ostream& out, int Array[50][50], int Row, int Column )
{
    string FileName = GetFileName();
 
    int FilledArray = ArrayFiller();
 
    ofstream FileOut;
     
    FileOut.open(FileName);
 
    FileOut << FilledArray ;
 
}
Last edited on
You never call PrintArray anywhere.
Topic archived. No new replies allowed.