Submitting a trivial correction to a CS assignment/coursework (i.e. source code)
Contact your professor.  First, stop trying to trivialize your error - it's big enough that your code won't compile, so it's a serious error and that's that.  If the assignment marking requires them to run your code, then you are assured to get a 0 for code that doesn't compile, so you've honestly got nothing to lose here.  If, on the other hand, it's marked by hand without running it, then you need to address the error and how it happened.  This is especially an issue if you showed output from a previous version of the code - you submitted code that clearly didn't produce that output, and that can sometimes be construed as academic dishonesty.

Your professor has probably been around long enough (read: a few days) to understand that undergrads sometimes submit code with errors accidentally.  Perhaps they submitted the previous version by mistake, or fixed "just one little thing" and forgot to test it.  You would not be the first such student, and usually the professor will not get angry about it.

However, all of this being said, this doesn't mean that the prof needs to actually do anything about it.  Depending on their particular style, you might get ignored.  For instance, if everyone had the same deadline and it has long since passed, then submitting a correction is probably not something that the prof will allow - what evidence does this professor have that you didn't spend extra days perfecting bad code and now are ready to submit it?

But to answer the original question - these sorts of requests are made all the time, and it is unlikely to affect you negatively.  The longer you wait, the worse this gets.