+ 1

error code

here is my code i can find reverse but get error code as below: Process finished with exit code -1073741819 (0xC0000005) int main() { int size; cin>>size; int *arr=new int(size); for(int i=0;i<size;i++){ cin>>arr[i]; } for(int i=0;i<size;i++) { cout<<arr[size-(i+1)]<<" "; } return 0; }

23rd Nov 2021, 5:48 PM
titan
6 Antworten
+ 3
can you include the problem plz and thx
23rd Nov 2021, 6:00 PM
Jackson Jameson
Jackson Jameson - avatar
+ 2
i also ask on stackoverflow and i realised i have typo int *arr=new int[size]; instead of int *arr=new int(size); thank you for your contrubition
23rd Nov 2021, 6:27 PM
titan
+ 1
entering nums and reversing array basically for ex: input: 3 2 5 8 output: 8 5 2
23rd Nov 2021, 6:06 PM
titan
0
i got 8 5 2 for the out put
23rd Nov 2021, 6:14 PM
Jackson Jameson
Jackson Jameson - avatar
0
yes but when you give larger size it gives error code for ex: 9 346 34 234 346 43 123 654 234 123
23rd Nov 2021, 6:18 PM
titan
0
try to not add spaces I took out the spaces and it worked
23rd Nov 2021, 6:22 PM
Jackson Jameson
Jackson Jameson - avatar