I am having trouble having the data shown once the program has compiled in codeb
ID: 3704863 • Letter: I
Question
I am having trouble having the data shown once the program has compiled in codeblocks. I have used command lines -std=c++11 And ./g.out -s And also wrote a method to print data to console Nothing seems to work Help would be appreciated tart here selectionSort.cpp.cpp catch.hpp.cpp Edefine CATCHLCONFIG MAIN tinclude ciostrea include evectorn #include "cotch.hpp.cpp" sort o[e],,a[size-1] in ascending order void selectionSort(double aD,int size) Harsh- bash 80x24 int i, iMax; double aTemp for (int n-size 2; n-) Last login: Tue Apr 1e 14:41:33 on ttyseee Users/Harsh/Desktop/CS124/C++foryouchapter9/src/sele Harshs-Air:- Harshs /Users/Harsh/Desktop/C5124/C+for rt.cpp 10 12 13 14 15 16 //find the index "imax" of the largest element Alt tests passed (2 assertions in 1 test case) //swop a[Max] with a (n-1 Harshs-Air Harshs a(Max]-a[n-1] ; a(n-13- aTemp; //Sove o[Max) in a temporary Tocotion 77copy a[n-1] to a Max 19 copy saved value to otn-1) 21 23 24 25 26 27 using Catch:: Matchers::Equals; TEST-CASE ("select ionSort") const int N-6 double x1[N]-(1.1,3.3,5.5,6.6,4.4,2.2 double xžIN)-1.1,2.2,3.3,4.4,5.5,6.6: std:: vector v2(x2, x2.N): REQU?RE.NAT(v1.not Equals(v2)); selectionSort(x1, N) 31 32 std:: vectorExplanation / Answer
This somtimes happen when "segment fault" occurs that is the program is accessing memory locations of computer which should not be accessed such as some other programs memory location, operating system's memory or any other invalid location of memory. This cause compiler to inaccessibility to output file and access is denied.
Following are the reasons of this error:
1) setting another locations data as NULL (using pointers),
2) setting another locations memory to an uninitialized pointer,
3) calling a pointer that has been dealocated the memory in the program previously
4) an array go out of scope or writing to the end of array out of bound.
These errors can be corrected as follows:
1) Write your program in small chunks which are executable one by one, this help you to see where the problem is occuring.
2) All pointers should be checked, and shouldnt be uninitialized.
3) Check all arrays to be in its memory alocated that is they must be in their bounds.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.