How could I initialize variables I want to input data in?

I'm getting:

In function 'void arrReplace()':
9:14: warning: 'arrname' is used uninitialized in this function [-Wuninitialized]
In function 'void arrInputSize()':
14:12: warning: 'n' is used uninitialized in this function [-Wuninitialized]
In function 'void arrInput()':
18:16: warning: 'n' is used uninitialized in this function [-Wuninitialized]
In function 'void endConfig()':
26:16: warning: 'n' is used uninitialized in this function [-Wuninitialized]

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
  #include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

void arrReplace(){
    string *arrname;
        cout<<"Input array name\n";
cin>>*arrname;
}
void arrInputSize(){
    int *n;
    cout<<"Input number of elements\n";
    cin>>*n;
}
void arrInput(){
    int *n;
    int *arr[*n];
for(int x=0;x<*n;x++){
        cout<<"Input "<<x++<<" array element";
        cin>>*arr[x];
    }
}
void endConfig(){
    int *n;
    int *arr[*n];
    char answer;
    string *arrname;
cout<<"Result: "<<*arrname<<"[";
    for(int x=0;x<*n;x++){
        cout<<*arr[x];
    }
    cout<<"], "<<n<<" elements.\n Wanna change something?\nO.No\nA.Yes";
    cin>>answer;
    while(answer!='O'){
        cout<<"What exactly?\nA.Name\nB.Number of elements\nC.Array values\nO.Nothing";
    }
    if(answer=='A'){
        void arrReplace();
    }
    if(answer=='B'){
        void arrInputSize();
    }
    if(answer=='C'){
        void arrInput();
    }
    cout<<"Result: "<<*arrname<<"[";
    for(int x=0;x<*n;x++){
        cout<<*arr[x];
    }
    cout<<"], "<<*n<<" elements.";
}
int main()
{
     arrReplace();
     arrInputSize();
     arrInput();
     endConfig();
     return 0;
}

There are so many errors in your code it's hard to know where to start.

But the first question is why all the pointers, uninitialized pointers I should add?

Registered users can post here. Sign in or register to post.