What does it mean when code builds successfully, but doesn't run

Hey!
I have a problem with a program not running. What does it mean when the compiling works, but running the program fails?
I use Visual Studio 2017 btw.

Appreciate all answers:)
Hello ramp00,

The answer to your question is 42. https://www.youtube.com/watch?v=aboZctrHfK8

With out seeing the code one can only guess that you have no syntax errors in the code, but may have logic errors.

Post your code so everyone knows what you are working with.

Andy
what did you mean by fail? did it crash? Did it open a console, generate output, succeed, and close before your finger left the mouse you clicked it with (try adding a cin statement to the end of your program). If it crashed, it means that your syntax was legal but it did something illegal, like trying to modify memory that belongs to a different program (there are an awful lot of ways to crash a program with legal code, this is ONE example).

if it crashed, you have to figure out why and fix it.
Hahha read The hitchhiker's guide to the galaxy recently, great book;)
But yeah, sorry. Horrible explanation from my side..

I think I found my error though.
The error message from VS was:
fatal error C1075: '{': no matching token found


1
2
3
4
5
6
if ((tallNedre >= 65 && tallNedre <= 90) && (tallOvre >= 65 && tallNedre <= 90)) { //blahblah
....
....
...
...
}


Apparantly the "//blahblah" comment made the code fail.
I thought commenting inside the code wouldn't affect the surrounding code, but I suppose I was wrong.
When is the "//" comment applicable, and is there any other way to comment inside the code without ruining it?

foo( /*bar*/ input);
// is until end of this line.
/* is until it sees */, can be many lines or part of one line.
c++ standard is grumpy about nested /* commenting but most compilers deal with it with just a warning.

c++ is also whitespace tolerant.

if(stuff) //if stuff is true do things end of line comment is often all you want or need
but you can also just break the line for most code
if(this && //if this is true, and that is true, then do stuff)
that)

the above is ugly but there are places where it makes sense to do that, and places where it just uglies the code. use your best judgement.
Last edited on
Well if your code snippet is actually exactly the same as the actual code there is nothing wrong with that snippet. As long as there is nothing after that comment (other than a carriage return character) there should be no problem.

The C++ style comments "//" are used for single line comments, everything after the "//" up to the end of the line are part of the comment.

Don't forget that you could also use C style comments /* This is C style comment */ that have a beginning and ending sequence only the characters between the "/*" and "*/" are part of the comment.

Hmm, yeah I see.
Thanks guys!
Topic archived. No new replies allowed.