Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am trying to create code, that takes a file and places the contents into an array A. I am working in pieces and right

I am trying to create code, that takes a file and places the contents into an array A. I am working in pieces and right now, my program is giving me a segmentation fault. Does anyone know why this is happening or how i can fix this?

Thanks

#include #include #include #include #include #include using namespace std;

int getInvCount(vector B, int n) { int invCount = 0; for(int i=0; i < n-1; i++) { for(int j = j+1; j < n; j++) { if (B[i] > B[j]) { invCount++; } } } return invCount; }

int main(int argc, char * argv[]) {

int counter = 0; vector A; string filename; ifstream inFile; filename = argv[1];

int n = sizeof(A) / sizeof(A[0]); cout << "Output: " << endl;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

nin. idterm 2 MCQ- Chapter 5, 6, 7 and 8 Question 13 of 25

Answered: 1 week ago