Thanks jonnin - I already added a vector to replace the array. No one taught vectors yet so I doubt the lab's professor will be very pleased to see it, but at most it'll be a few docked points. At best, he'll understand that its not a C++ function and not make a statement about me not using their Linux weird things to code. Also, vectors are usually frowned upon in these courses because they literally solve all your problems. Since he doesn't expect any of us to use any memory management, I think it should be fine.
your professors really should know better |
If you saw half the stupidity I've witnessed, this is just nothing in comparison. Had to write code that did something stupid using nested loops. The issue is that it was so simple you only needed 1 loop. In the end, to use a nested loop, you had to split the work about 90/10 between the loops. Not only was it hard to implement (I think only 1 student other than me actually figured it out if any others at all), but you had to make a new variable and if statement to break out of the loop. There was no way to have the nested loop stop from its condition. It was just a giant mess. It was to enforce the knowledge of nested loops, but it instead just showed students how to write bad code.
After explaining how horrible it was, he said it still had to be done this way. So I made another loop and shoved the already done loop inside, told him I fulfilled the requirements. He looked at me and said something along the lines of, "You know that's not what I wanted." So I coded it "correctly" and turned it in.
Thanks also Duthomhas, read the posts, they get real into it xD . Seems that it would be nice to have VLAs, especially since a lot of compilers seem to allow them anyway. I can see it would cause some contradictions with existing standards, but one can always make compiler acceptable code that breaks. Maybe I don't know enough to speak on this though.
Thanks guys!