Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Microsoft Visual Studio C++ error

  1. Nov 9, 2012 #1
    Hello,

    I'm new to Microsoft Visual Studio and new to the C++ program. I just installed the program and I'm trying to write my first program.

    First error that I get is: ========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========

    Why is my project out-of-date?

    Second error: Since my project is out of date, I'm asked if I want to build my project, I click yes.

    The 'black' screen appears for a second and then it disappears.

    Am I doing something wrong? Can someone help me please?

    Thanks a lot for your help
     
  2. jcsd
  3. Nov 9, 2012 #2
    That's not an error. It says it's "up-to-date." That just means that you already compiled the code once, and you haven't changed anything, so the executable you built is already up to date.

    Again, your project is NOT out-of-date. It's up-to-date.

    The black screen is probably your program running, and then closing again. I don't know what your code is doing, but it probably exits as soon as it's done printing what you wanted to print. Try adding this line before your main() function returns:

    system("pause");

    This will cause the program to prompt for user input before exiting, allowing you to see what you printed.
     
  4. Nov 9, 2012 #3
    The following image shows the program that I'm writing and the error that I'm getting. I hope this helps.

    error.jpg

    After I click yes, the programs runs for 1 second "the black window" appears and then it disappears.
     
  5. Nov 9, 2012 #4
    That's not an error; that's just a message that means "we noticed that you've changed your code since you last built an executable." It's just asking if you want to re-compile so your executable is more recent.

    The black window is occurring because of the reason I explained in my last post.
     
  6. Nov 9, 2012 #5
    When I press the ctrl + F5 it works.

    But when I write system ("pause") before the int main, it doesn't.

    Thanks a lot for your help, appreciated.
     
  7. Nov 9, 2012 #6
    Add "system("pause");" before the "return 0;" line in your main() function, like so:

    int main()
    {
    cout << "Hello";
    system("pause");
    return 0;​
    }
     
    Last edited: Nov 9, 2012
  8. Nov 9, 2012 #7
    Finally it worked out. Thanks a lot :D
     
  9. Nov 9, 2012 #8

    rcgldr

    User Avatar
    Homework Helper

    You could also set a debugger breakpoint on the return 0, then run the program, which will stop at the breakpoint, allowing you to see the console window as well as your program varialbes (from the debugger).
     
  10. Nov 9, 2012 #9
    Can you explain more rcgldr? I didn't get your point.
     
  11. Nov 9, 2012 #10

    rcgldr

    User Avatar
    Homework Helper

    Assuming you're working in "debug" mode for your project, click on the line with the return 0, and press F9 (this could change with different versions of Visual Studio). You could also just right click on the line with return 0, and then click on "run to cursor". Visual Studio will then stop the program just before doing the return 0, which will prevent the console (black) windows from going away, and allow you to examine variables.
     
  12. Nov 9, 2012 #11

    Borek

    User Avatar

    Staff: Mentor

    Alternatively - with cursor in the return 0; line - press Ctrl-F10. That's just another way of invoking "run to the cursor" command.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Microsoft Visual Studio C++ error
  1. Issues with C++ errors? (Replies: 13)

Loading...