Start New Discussion within our Software Development Community
1.
      //my main
   2.
      int sizeOfArray;
   3.
       
   4.
      int main()
   5.
      {
   6.
      int i;
   7.
      int *num1, *num2, *num3, *num4, *num5;
   8.
      string *opening, *ending;
   9.
      cin >> sizeOfArray;
  10.
      command = new string [sizeOfArray];
  11.
      opening= new int [sizeOfArray];
  12.
      num1= new int [sizeOfArray];
  13.
      num2= new int [sizeOfArray];
  14.
      num3= new int [sizeOfArray];
  15.
      num4= new int [sizeOfArray];
  16.
      num5 = new int [sizeOfArray];
  17.
      ending= new string [sizeOfArray];
  18.
       
  19.
      for(i= 0; i< sizeOfArray;){
  20.
      cin >> opening[i];
  21.
      if (opening[i] == "hello"){
  22.
      hello(_____);}
  23.
      if (opening[i] == "world"){
  24.
      world(_____);}
  25.
      i++;}
1.
      //void hello
   2.
      void hello(______)
   3.
      {
   4.
      cin >> num1 [i] >>num2 [i] >>num3[i] >>num4[i] >>num5[i];
   5.
      getline(cin,ending[i];
   6.
      }
1.
      //void world
   2.
      void select()
   3.
      {
   4.
      int a,b,c,d;
   5.
      cin >> a >> b >> c >> d;
   6.
       
   7.
      for(int k= 0; k< sizeOfArray; k++){
   8.
      cout << num1 [k] << endl; // <-- here, cannot get correct value of num1 that i input before
   9.
      }}

input:
2
hello 1 2 3 4 5 bye
world 7 7 7 7
(the output is some meaningless number, seems to be an address)

num1 only exists within the scope of main, you must pass it into your function to use it.

I have been reading your posts and I think that you are missing some fundamental ideas. If you have a textbook, go back and reread the appropriate sections, as your misperceptions are going to be harmful to your coding.

This question has already been answered. Start a new discussion instead.