I just started to learn about C++, but my professor hasn't said anything about getting an error like mines. I'm trying to run it on Visual Studio 2010 Express and my program runs until a certain point then crashes, and I received this error message. I tried asking for help from people I know, but they say that my coding is correct and didn't know how to help me.
1 2 3 4 5 6
'Linh.exe': Loaded 'C:\Users\Houng\Documents\Visual Studio 2010\Projects\Linh\Debug\Linh.exe', Symbols loaded.
'Linh.exe': Loaded 'C:\Windows\System32\ntdll.dll', Symbols loaded (source information stripped).
'Linh.exe': Loaded 'C:\Windows\System32\kernel32.dll', Symbols loaded (source information stripped).
'Linh.exe': Loaded 'C:\Windows\System32\msvcp100d.dll', Symbols loaded.
'Linh.exe': Loaded 'C:\Windows\System32\msvcr100d.dll', Symbols loaded.
The program '[7988] Linh.exe: Native' has exited with code 0 (0x0).
'Linh.exe': Loaded 'C:\Users\Houng\Documents\Visual Studio 2010\Projects\Linh\Debug\Linh.exe', Symbols loaded.
'Linh.exe': Loaded 'C:\Windows\System32\ntdll.dll', Symbols loaded (source information stripped).
'Linh.exe': Loaded 'C:\Windows\System32\kernel32.dll', Symbols loaded (source information stripped).
'Linh.exe': Loaded 'C:\Windows\System32\msvcp100d.dll', Symbols loaded.
'Linh.exe': Loaded 'C:\Windows\System32\msvcr100d.dll', Symbols loaded.
The program '[7988] Linh.exe: Native' has exited with code 0 (0x0).
These are not errors. The first five are informational messages generated by the debugger. The last informational messages says that your program has finished execution and has ended normally.
// This program asks the user to enter the amount of each item bought, so
// that the user will know the total amount. It will do so by adding the items
// to get the subtotal, then by multiplying by the sales tax. Then the total
// will be displayed on the screen.
#include <iostream>
usingnamespace std;
int main()
{
double item1, item2, item3, item4, item5, subtotal, tax, total;
cout << "This program will help you know the total amount of ";
cout << "money when purchasing your five items. " << endl ;
// Getting how much each item cost.
cout << "How much did item 1 cost? ";
cin >> item1;
cout << "How much did item 2 cost? ";
cin >> item2;
cout << "How much did item 3 cost? ";
cin >> item3;
cout << "How much did item 4 cost? ";
cin >> item4;
cout << "How much did item 5 cost? ";
cin >> item5;
// Calculate subtotal.
subtotal = item1 + item2 + item3 + item4 + item5;
// Display the subtotal.
cout << "The amount so far is $ " << subtotal << ".\n";
// Display total with sales tax.
tax = .06;
total = subtotal * (1 + tax);
cout << "Your total with the 6% sales tax is $ " << total << endl;
return 0;
}
> I added a system("pause") after my last cout and it works perfectly.
Avoid constructs like system("pause") if possible. The reason is something that you may not want to worry about right now (very briefly, it creates a vulnerability in your code which can be subject to an exploit); and it is probably not relevant in this particular case. But it does not make sense to get into bad habits right now; it is surprisingly difficult to unlearn wrong things that you have already learned.
Although it says not to do that, my Professor specifically said he didn't want anything in our coding that hasn't been taught to us. Since it's our first homework assignment I kind of thought just adding the (1 + tax) was pushing my luck. Since he has talked about the system("pause") before, I thought it would be okay to use it.
hi,
i am also new and getting really confused.
is there a way to change the settings of the vc 2010 express such that the console will remain open until a key is pressed??
i am getting these messages curently and the console disappears almost immediately after it appears
'hallo.exe': Loaded 'C:\Users\Documents\Visual Studio 2010\Projects\hallo\Debug\hallo.exe', Symbols loaded.
'hallo.exe': Loaded 'C:\Windows\System32\ntdll.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\kernel32.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\KernelBase.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\msvcr100d.dll', Symbols loaded.
'hallo.exe': Loaded 'C:\Windows\System32\apphelp.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\AppPatch\AcLayers.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\sspicli.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\msvcrt.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\rpcrt4.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\user32.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\gdi32.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\lpk.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\usp10.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\shell32.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\shlwapi.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\ole32.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\oleaut32.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\userenv.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\profapi.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\winspool.drv', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\mpr.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\AppPatch\AcGenral.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\sechost.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\uxtheme.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\winmm.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\samcli.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\msacm32.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\advapi32.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\version.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\sfc.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\sfc_os.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\dwmapi.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\setupapi.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\cfgmgr32.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\devobj.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\urlmon.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\wininet.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\iertutil.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\crypt32.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\msasn1.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\AppPatch\AcXtrnal.dll', Symbols loaded (source information stripped).
FTH: (4944): *** Fault tolerant heap shim applied to current process. This is usually due to previous crashes. ***
'hallo.exe': Loaded 'ImageAtBase0x190000', Loading disabled by Include/Exclude setting.
'hallo.exe': Unloaded 'ImageAtBase0x190000'
'hallo.exe': Loaded 'C:\Windows\System32\shunimpl.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\SortWindows6Compat.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\imm32.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\msctf.dll', Symbols loaded (source information stripped).
'hallo.exe': Loaded 'C:\Windows\System32\psapi.dll', Symbols loaded (source information stripped).
The program '[4944] hallo.exe: Native' has exited with code 0 (0x0).
All you needed to do is run the program with the debugger on. >_>
[sobbing]No, Running with the debugger on will treat the program as if you double clicked the icon in explorer, a console window will open the program will run and at the end the window will close.[/sobbing]