c++ - Project loaded error after debugging -
edit: took guys' advice , program compiles. can't run because these errors.
'baseconverter.exe': loaded 'c:\users\ownert\documents\visual studio 2010 \projects\baseconverter\debug\baseconverter.exe', symbols loaded. 'baseconverter.exe': loaded 'c:\windows\system32\ntdll.dll', cannot find or open pdb file 'baseconverter.exe': loaded 'c:\windows\system32\kernel32.dll', cannot find or open pdb file 'baseconverter.exe': loaded 'c:\windows\system32\kernelbase.dll', cannot find or open pdb file 'baseconverter.exe': loaded 'c:\windows\system32\msvcp100d.dll', symbols loaded. 'baseconverter.exe': loaded 'c:\windows\system32\msvcr100d.dll', symbols loaded. program '[5320] baseconverter.exe: native' has exited code 0 (0x0).
here's new updated code. fixed std::cout , have eliminated namespaces, think overloaded coding.
converter.h
#ifndef converter_h #define converter_h using std::cout; using std::cin; using std::endl; //this contains function types needed //reading input //converting base base10 //convert base10 base extern int non10num; extern int bin; extern int bout; extern int b10num; extern int conv; extern int option; extern int sum; extern int num; #endif
convertion.cpp
#include <iostream> #include <cmath> #include <string> #include <cctype> #include "converter.h" using std::cout; using std::cin; using std::endl; int non10num = 0; int bin = 0; int bout = 0; int b10num = 0; int conv = 0; int option = 0; int sum = 0; int num = 0; int main () { //reinstates int variables int pow = 1; while (option) { sum += b10num * pow; num /= 10; pow *= non10num; } }
converter.cpp
#include <iostream> #include <cmath> #include <string> #include <cctype> #include "converter.h" using std::cout; using std::cin; using std::endl; extern int non10num; extern int bin; extern int bout; extern int b10num; extern int conv; extern int option; extern int sum; extern int num; //this brings menu void menu() { cout << "1. base base" << endl; cout << "2. base base-10" << endl; cout << "3. base-10 base" << endl; cout << "4. exit" << endl; cout << "" << endl; cout << "choose option: "; cin >> option; switch (option) { case 1: cout << "enter integer: "; //asks user input cin >> non10num; cout << "enter base belongs to: "; cin >> bin; cout << "enter base should converter: "; cin >> bout; cout << non10num << " in base " << bin << " " << non10num%bin << " in base " << bout<< endl; //converts data break; case 2: cout << "enter integer: "; cin >> non10num; cout << "enter base belongs to: "; cin >> bin; cout << non10num << " in base " << bin << " " << non10num%10 << " in " << b10num; break; case 3: cout << "enter integer: "; cin >> b10num; cout << "enter base integer converted: "; cin >> conv; cout << b10num << " in base 10 " << b10num%10 << " in "<< conv; break; case 4: //exits menu return ; break; default: cout << "you have entered invalid option!" << endl; } while (option!=0); return ; }
define each 1 in one of cpp files:
int bin = 0;
and declare in others:
extern int bin;
as stands, you're violating 1 definition rule.
also, right now, you're declaring variables of same names in main()
going hide global variables in function, not want.
Comments
Post a Comment