#include <iostream> #include <string> using namespace std; int func_input(int); int main() { const int MAX=10; int task_arr[MAX]; func_input(task_arr[MAX]); } int func_input(int op_arr[],int size) { for(int i=0;i<=size;++i) { cout<<i<<") "; cin>>op_arr[i]; cout<<""<<endl; } } 

Displays error

Id returned 1 exit status

  • You do not pass the size of the array, func_input(task_arr[MAX],MAX); - LighFusion
  • @LighFusion, he doesn’t compile the code at all ... - Qwertiy
  • @qwertiy - in your answer it is better to present the function not as an int. And as void once this is a handler, nothing will need to be returned. - LighFusion
  • @LighFusion, corrected. I ruled until I compiled it and did not notice this moment. By the way, why did this ideone decide to keep silent on such an error? Like VS cursed ... - Qwertiy
  • Hmm .. Who then puts the pros for podsovyvanie uncompiled code under the guise of working? o_O - Qwertiy

1 answer 1

If you fix compile errors and loop errors, then everything works well.

http://ideone.com/t2nTj3

In general, the problem may be related to the string

 for(int i=0;i<=size;++i) 

in which the array goes beyond the boundary.

Or with the fact that the compiler is dubious and does not know how to do

 return 0; 

in main.

  • Thank you all, I added the parameters to the function initialization, as advised by the speaker from above. void func_input (int op_arr [], int size); - Ilya Yurin