So i have just started learning C++ and i started with the hello world tutorials and that went good i got it to open no problem butnow i am trying to do the calculator like so
#include <iostream>
int add(int x, int y)
{
// add the numbers x and y together and return the sum
std::cout << "running calculator...\n";
return (x+y)
}
int main()
{
/*this program calls an add() function to add two diffrent sets of numbers together and displays the results. the add() function dosnt do anything unless it is called by a line in the main() function. */
std::cout << "what is 867 + 5309?\n";
std::cout << "the sum is " << add(867, 5309) << "\n\n";
std::cout << "what is 777 + 9311?\n";
std::cout << "the sum is " << add(777, 9311) << "\n";
return 0;
}
and it keeps opening the Hello World window when i click run on the calculator...i notice to that in my files folder it auto creates a main.cpp...i figure its something im doing wrong but i cant pinpoint it any help would be much appreciated.
thanks in advance
Turn on Full Compiler Logging; then read/post the full compiler log after doing re-build of the project.
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F (http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_%28errors%29#Q:_How_do_I_troubleshoot_a_compiler_problem.3F)
Tim S.
Quotei notice to that in my files folder it auto creates a main.cpp
Put your code in the auto-created main.cpp.
so i turned on full compiler logging i just wasnt 100% sure where to get the log but i hope this is right
Building to ensure sources are up-to-date
Build succeeded
Selecting target:
Debug
Adding source dir: C:\Users\owner\Desktop\C++\calc\
Adding source dir: C:\Users\owner\Desktop\C++\calc\
Adding file: bin\Debug\calc.exe
Starting debugger:
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb 6.8
Child process PID: 6104
Program exited normally.
Debugger finished with status 0
i started from scratch and remade it and still opens the Hello World instead
Please post the Build log (after turning on FULL COMPILER LOGGING) not the log you posted after you do a re-build of project.
You likely are NOT compiling the right file.
NOTE: to do a re-build choose "rebuild" from the "build" menu.
Tim S.
-------------- Clean: Debug in calc ---------------
Cleaned "calc - Debug"
-------------- Build: Debug in calc ---------------
mingw32-g++.exe -Wall -fexceptions -g -c C:\Users\owner\Desktop\C++\calc\main.cpp -o obj\Debug\main.o
mingw32-g++.exe -o bin\Debug\calc.exe obj\Debug\main.o
Output size is 913.65 KB
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings
i got it to work by putting the source in main.cpp that gets auto created in my calc folder like Neil Butterworth said(thank you) i still
dont know how it is being created it has the "Hello World" source code in it but anyway after i did that and fixed an error i managed to
find in the code it worked just fine thanks again :)