program won't run in VC++ Express

This is a discussion on program won't run in VC++ Express within the C++ Programming forums, part of the General Programming Boards category; Hi everyone.. This code was from a book and I was trying to compile it with VC++ Express. Code: #include ...

  1. #1
    Registered User
    Join Date
    Dec 2006
    Location
    Jacksonville, AR
    Posts
    91

    program won't run in VC++ Express

    Hi everyone..
    This code was from a book and I was trying to compile it with VC++ Express.

    Code:
    #include <cstdio>
    #include <cstdlib>
    #include <iostream>
    using namespace std;
    
    int main (int nNumberofArgs, char * pszArgs[]);
    {
    	//enter the temperature in celsius
    	int celsius;
    	cout <<"Enter the temperature in celsius: ";
    	cin >> celsius;
    	
    	//calculate conversion factor for celsius to fahrenheit
    	int factor;
    	factor = 212 - 32;
    	
    	//use conversion factor to convert celsius into fahrenheit value
    	int fahrenheit;
    	fahrenheit = factor * celsius/100 + 32;
    
    	//output the results (followed by an Newline)
    	cout <<"Fahrenheit value is: ";
    	cout <<fahrenheit <<endln;
    
    	//wait until user is ready before terminating program to allow the
    	//user to see the program results
    	system ("PAUSE");
    	return 0;
    }
    And this is the error I get. I probably didn't include necessary files. I am new at C++ and I am still learning my way to libraries and such.
    Thanks...

    Code:
    'temp.exe': Loaded 'C:\Documents and Settings\Tangog\My Documents\Visual Studio 2005\Projects\temp\debug\temp.exe', Binary was not built with debug information.
    'temp.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.
    'temp.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.
    The program '[1556] temp.exe: Native' has exited with code 0 (0x0).

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    It looks like it runs fine to me - I'm a little bit suprised that it exits after the "system("PAUSE")", but it looks like it runs fine - you didn't build the debug version, and you don't have a symbol server set up [nor should you need one - but that is why you get some "No Symbols loaded" - but unless you actually intend to debug kernel32.dll or ntdll.dll, you don't need those symbols].

    Try building your code as debug instead, and then set a breakpoint on the beginning of main (put the cursor at "int celsius;" and hit F9 on the keyboard). Run it in the debugger and see if you get there.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Or use Ctrl+F5 to launch your program, it should stay open.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,453
    > int main (int nNumberofArgs, char * pszArgs[]);
    The ; at the end of this line means you didn't compile this code.
    Also, calling the arguments anything other than argc and argv is more confusing, especially when you attempt to replace them with Hungarian notation equivalents.

    > 'temp.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.
    This just means that should you want to dig really deep into the library code your program calls, you'll find it hard without the symbols. It doesn't affect how your code runs, nor the ability to debug your code.

    > The program '[1556] temp.exe: Native' has exited with code 0 (0x0).
    Exit with code 0 is good, it means your program ran successfully.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Dec 2006
    Location
    Jacksonville, AR
    Posts
    91

    Smile

    Hi all,
    Now it's running but all I get is a blank window; no outputs.. Do I need to include something else, a library perhaps?
    Thanks guys..

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,453
    Post your current program attempt.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    Dec 2006
    Location
    Jacksonville, AR
    Posts
    91

    Unhappy

    Quote Originally Posted by matsp View Post
    Try building your code as debug instead, and then set a breakpoint on the beginning of main (put the cursor at "int celsius;" and hit F9 on the keyboard). Run it in the debugger and see if you get there.
    Mats
    How do I build it as debug and how will I run it in the debugger? Sorry.. please bear with me.

    Quote Originally Posted by Salem View Post
    Post your current program attempt.
    Can you please tell me how?

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I think Salem meant "post the source code as it is now".

    As to building for debug [1], If you right-click on your project pane (the bold name of your project) and select the "Properties", you will get a dialog box <project> Property Pages. One of the fields is a "Configuration manager", which gives another dialog. This box has a "Active Solution Configuration" selection box - select "Debug".

    Once you have a debug build, just press F5 to run - or select Debug->Run in the main menu.


    [1] This is not based on a VC++ 2005 but VC++ .Net, but from what little I tried it, I think it was the same when I used the 2005 version.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  9. #9
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    >> How do I build it as debug and how will I run it in the debugger?
    It should be built in debug mode by default (you can check by going to Build > Configuration Manager and verifying that the solution configuration is Debug).

    You are already running it through the debugger, the output you posted is what happens when you run the program through the debugger. You either hit F5 or selected Debug > Start Debugging or clicked the triangular play button on the toolbar.

    What might be happening is that generating debug info got turned off. Go to Project > Properties. Select Configuration Properties > C/C++ > General and make sure that the Debug Information Format is set to Progam Database (/Zi) or Progam Database for Edit & Continue (/ZI). Then Rebuild Solution to make sure it gets generated.

    >> Post your current program attempt.
    This means post your current code like you did at the start of this thread.

  10. #10
    Registered User
    Join Date
    Dec 2006
    Location
    Jacksonville, AR
    Posts
    91

    Smile

    Here's the current program. I really didn't change anything except for the semicolon after the int main line. You guys were right, the debug setting was disabled. I changed it to program database format (/Zi) but the output is still the same, just a blank screen.

    Code:
    #include <cstdio>
    #include <cstdlib>
    #include <iostream>
    using namespace std;
    
    int main (int nNumberofArgs, char * pszArgs[])
    {
    	//enter the temperature in celsius
    	int celsius;
    	cout <<"Enter the temperature in celsius: ";
    	cin >> celsius;
    	
    	//calculate conversion factor for celsius to fahrenheit
    	int factor;
    	factor = 212 - 32;
    	
    	//use conversion factor to convert celsius into fahrenheit value
    	int fahrenheit;
    	fahrenheit = factor * celsius/100 + 32;
    
    	//output the results (followed by an Newline)
    	cout <<"Fahrenheit value is: ";
    	cout <<fahrenheit <<endln;
    
    	//wait until user is ready before terminating program to allow the
    	//user to see the program results
    	system ("PAUSE");
    	return 0;
    }
    What could possibly be missing here?

  11. #11
    Registered User
    Join Date
    Dec 2006
    Location
    Jacksonville, AR
    Posts
    91

    Smile

    Code:
    .\temperaturecomputation.cpp(23) : error C2065: 'endln' : undeclared identifier
    I forgot to post the error.. Here goes, guys..
    Last edited by alyeska; 09-28-2007 at 10:16 PM. Reason: wrong code

  12. #12
    NotSoAvgProgrammer
    Join Date
    Jul 2007
    Location
    Virginia, U.S.
    Posts
    57
    I believe endln should be endl


    P.S. Youd need to learn to read the compiler errors.
    (23) Is the line you should be looking at (general area)
    'endln' specific peace of code compiler had problem with
    undeclared identifier Compiler hasn't heard of it, (doesn't know about it).
    Last edited by avgprogamerjoe; 09-28-2007 at 10:19 PM.
    A quality job is not necessarily a *good* job. A quality job is, by definition, conformance to requirements. Therefore a *good* job, may not be a quality job.

  13. #13
    Registered User
    Join Date
    Dec 2006
    Location
    Jacksonville, AR
    Posts
    91

    Smile

    Thanks avg.. I corrected it. It still said no debugging information but I went ahead and continued and it actually worked! Is that good enough though? This is what it said:

    Debugging information for 'temp.exe' cannot be found or does not match. Binary was not built with debug information.
    Do you want to continue debugging?

  14. #14
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by alyeska View Post
    Thanks avg.. I corrected it. It still said no debugging information but I went ahead and continued and it actually worked! Is that good enough though? This is what it said:
    It means that you are building the "Release" version of your code. Try setting it to "Debug" as pointed out by me and Daved earlier.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  15. #15
    Registered User
    Join Date
    Dec 2006
    Location
    Jacksonville, AR
    Posts
    91

    Smile

    Thanks mats, it is actually in the debug version. Anyway, it's running now and thanks to all of you.. Final code is:

    Code:
    #include <cstdio>
    #include <cstdlib>
    #include <iostream>
    using namespace std;
    
    int main ()
    {
    	//enter the temperature in celsius
    	int celsius;
    	cout <<"Enter the temperature in celsius: ";
    	cin >> celsius;
    	
    	//calculate conversion factor for celsius to fahrenheit
    	int factor;
    	factor = 212 - 32;
    	
    	//use conversion factor to convert celsius into fahrenheit value
    	int fahrenheit;
    	fahrenheit = factor * celsius/100 + 32;
    
    	//output the results (followed by an Newline)
    	cout <<"Fahrenheit value is: ";
    	cout <<fahrenheit <<endl;
    
    	//wait until user is ready before terminating program to allow the
    	//user to see the program results
    	system ("PAUSE");
    	return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 01:42 AM
  2. Help on making program run more efficiently
    By peeweearies in forum C Programming
    Replies: 2
    Last Post: 03-23-2009, 02:01 AM
  3. Client-server system with input from separate program
    By robot-ic in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-16-2009, 02:30 PM
  4. Re-doing a C program to run in Win2000 or XP
    By fifi in forum C Programming
    Replies: 5
    Last Post: 08-17-2007, 05:32 PM
  5. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21