So the code I'm writing is to read a file, sort it, then output back into the file. It was working fine the first time I did it, made changes my TA recommended, and now it's not working. I encountering the same breakpoint in xcode and then the rest of my code won't output. What's strange is my TA says it outputs just fine for him.
I did some research and figured out that it maybe it's the code trying to access something that hasn't been initialized yet? Would someone mind taking a look and possibly running it to maybe help me figure this out? I've got my main cpp, then two class cpps and headers. I'll post each section in a separate post.
One problem I see is that at line 17 you're accessing argv[2]. argv[0] is your program file name. At line 24, you check if argc is 2. This means you can only run your program successfully if you specify one argument. argv[argc] normally contains null to indicate the end of the argument list.
Therefore at line 32, you're passing null to bank.display. Accounts::Display is expecting a string, but is being passed a const char * which is null. string's constructor will try and copy the string pointed at by that null pointer causing a trap or exception.
I was taught that the command line has 3 arguments: 1 for input and 1 for output. If I used argv[1] twice I'd be overriding the the input file. Also, I was told by my TA to change the char parameters in my display function to a string. Either way it opens the file just fine.
But anyways that isn't the issue. I'm still getting breakpoints. To be more specific I'm getting them in my Account function. The first breakpoint is when it tries to access setLastName and it looks like specifically when trying to read the last name?