Computing.Net > Forums > Programming > C++ undefined symbol error message

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

C++ undefined symbol error message

Reply to Message Icon

Name: IDesignYards2
Date: February 11, 2007 at 18:36:48 Pacific
OS: windows xp
CPU/Ram: intel duo core 2 and 2GB
Product: Dell Inspirion
Comment:

I am trying to write a program to convert a base 10 number to another base. I keep getting an "undefined symbol main in" error. Can someone help me.
#include <iostream>
#include <iomanip>
#include <math.h>
#include <cmath>

using namespace std;

void main ( void )
{
int base10Num;
int newBase;
int quotient;
int rem;

cout<<"Enter any whole base 10 Number";
cin>>base10Num;
cout<<"Enter the base you want the base 10 number converted to: ";
cin>>newBase;

do
{
quotient=base10Num/newBase;
rem=base10Num%newBase;
switch(rem)
{
case'10':rem='A';
break;
case'11':rem='B';
break;
case'12':rem='C';
break;
case'13':rem='D';
break;
case'14':rem='E';
break;
case'15':rem='F';
break;
}
cout<<rem<<endl;
base10Num=quotient;
}
while(base10Num!=0)

}
any other suggestions would be very much appreciated! ty




Sponsored Link
Ads by Google

Response Number 1
Name: Guy
Date: February 12, 2007 at 15:04:51 Pacific
Reply:

You don't say if you are using MS Visual Studio or what ......

Under Linux, using g++, that code:

1) Needs a semi-colon after the

while(base10Num!=0)

2) main needs to return an int, not void. (Does MS allow this? If so, it is out of spec.)

3) You do not need quotes around the 'case' selectors, so not:

case '10':

but:

case 10:

That should at least eliminate compile errors.

What if I want base 42? How will that work?

Guy


0

Response Number 2
Name: IDesignYards2
Date: February 21, 2007 at 22:01:10 Pacific
Reply:

thank you very much for your help, I was using Code Warrior and next time will state that. I got the program to run successfully with your help, thanks again.


0

Response Number 3
Name: IDesignYards2
Date: February 21, 2007 at 22:08:33 Pacific
Reply:

using the Dibble Dabble method, you can convert to any base, even base 42. Don't know why you would want to do that, but it would work in this program also, except the conversion of the integer to a letter would not be appropriately figured out. The only bases I really need to convert to is binary and hexadecimal, so I wrote it for that.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


silent cmd shell from vbs... Batchfile not running as ...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: C++ undefined symbol error message

C error: Undefined symbol ceil www.computing.net/answers/programming/c-error-undefined-symbol-ceil/8138.html

Linker Error: Undefined Symbol www.computing.net/answers/programming/linker-error-undefined-symbol/13465.html

undefined symbol in c++ www.computing.net/answers/programming/undefined-symbol-in-c/11302.html