Chilton 22 Junior Poster

We are not allowe to use classes yet.

You are using iostream ;)

All joking aside, all your loop does is copy the next value to the position you planned on deleting, but that just makes two copies of the next position's data. The tedious way would be to use two loops. Once you've found the value to delete, start the next loop and copy the next value to the current position.

Also, why is your for loop checking for index < 9? Should it be inv.total?

Chilton 22 Junior Poster

Why not use a list of strings rather than a character array? The list class is made for fast insertion and deletion, without you having to worry about shifting values continually.

Chilton 22 Junior Poster

You could always just test for the student with the longest name, and find the difference in spacing between that name and every other name. In doing so, you can print the correct amount of spaces after each person's name, followed by the list of grades.

Good luck.

P.S. I'm originally from Brooklyn lol

Chilton 22 Junior Poster

There is no pAVec member in your class, and neither was one passed to the member function test.

Chilton 22 Junior Poster

The point wasn't to do the program for the person asking, though.

Nick Evan commented: True +16
Chilton 22 Junior Poster

In your catch statement, you referred to e but you never used it. Instead of

cout << "exception handled" << endl;

try

cout << e.what() << endl;

That should display the error string that you threw. If you want to specify it as an error, you could use cerr instead of cout as well.

Chilton 22 Junior Poster

What errors did you get?

Chilton 22 Junior Poster

Review the link that was posted before to get a better handling on loops, then try doing your program again.

Chilton 22 Junior Poster

If you're trying to pass the array to the function, you should just pass the name of the array "levelOnePlatform" as the first argument and 50, as the second argument which is its size.

Chilton 22 Junior Poster

Why the need to mix cout and printf?

Chilton 22 Junior Poster

If you've used "using namespace std;" then putting "using std::cout;" and "using std::cin;" isn't required.

Chilton 22 Junior Poster

One thing to note is that accumulate's third parameter, 0 in this case, makes your result an integer because the function takes that type as its value. Therefore, the fractional part of your code would be disregarded.

Change the 0 to 0.0.

Chilton 22 Junior Poster

I apologize if I wasn't explicit enough in telling you that.

Chilton 22 Junior Poster

I should've said declaration/prototype.

In the definition of Spr_Blit, you've specified the default. Remove it from there and put it in the prototype instead.

Also, it looks like you're passing functions as arguments to another function. There's a particular type of syntax that's involved in doing that.

int foo (int r) {
return r * r;
}

int main()
{
int (*pfoo)(int); // ptr to a function that accepts an int and returns an int
pfoo = foo;      // pfoo now points to the function foo
return 0;
}
Chilton 22 Junior Poster

Your default argument should be in the function's declaration.

Chilton 22 Junior Poster

What moschops was referring to was creating a variable of type string, rather than one of type char[]. That way, you'd be able to read in any name and test whether or not it's equal to "Jeanne" using the compare function.

Along with this, if you're initializing name to "Jeanne", then you shouldn't have the user try to change name. Lastly, you're testing name being equal to name, which is always going to be true. This doesn't actually compare the strings, themselves, but the address where they're located.

Chilton 22 Junior Poster

Oh, I'm actually saying you should check it to that. You've specified that MAX_ACCOUNTS is the amount you'd like the user to have, but elsewhere you've used a constant value i.e. 10 rather than the variable MAX_ACCOUNTS.

Your counter variable should be comparing itself to the amount you specified when you declared your array of objects. Still, you'd have a problem if the user exits before each object is given values. If you're specifying the amount of objects you'd want the user to utilize, then you could always remove the input test and have them read in data for MAX_ACCOUNTS amount of objects.

I apologize if I'm a bit wordy with this.

Chilton 22 Junior Poster

Even if you set MAX_ACCOUNTS to be 5, your do while loop still checks that counter is less than the integer 10 rather than MAX_ACCOUNTS, assuming that 1 is continually entered after counter surpasses MAX_ACCOUNTS.

You'd be pretty much trying to use an object that you never created, is what I think the problem is.

Chilton 22 Junior Poster

It should actually be "<= k" rather than less than.

Use 9 as an example and you'll see. The for loop ends and fails to mod 9 against 3, hence returning a value of 1.

Chilton 22 Junior Poster

You're not using any print statements with your array. Create a loop to display its elements.

Chilton 22 Junior Poster

Also, your code is overly complicated. Since you know the stopping value "maxElements", why not loop around that number of times while calling the pow function?