Comments...
Get rid of the tabs. You can see what happens when you assume 4 spaces and Daniweb assumes 8 spaces. Convert tabs to spaces.
//Generates alphabetical digits for the given base
void genDigs(int base,char *digs){
if (base>36){ //Because for bases greater than 36,the capital alphabets are not enough
for(int i=0;i<26;++i) //Generates capital alphabets
digs[i]=i+65;
for(int i=26;i<base-10;++i) //Generates small alphabets
digs[i]=i+71;
}
else
for(int i=0;i<base-10;++i) //Generates capital alphabets for bases smaller than 36
digs[i]=i+65;
} Much nicer.
//Generates alphabetical digits for the given base
void genDigs(int base,char *digs){
if (base>36){ //Because for bases greater than 36,the capital alphabets are not enough
for(int i=0;i<26;++i) //Generates capital alphabets
digs[i]=i+65;
for(int i=26;i<base-10;++i) //Generates small alphabets
digs[i]=i+71;
}
else
for(int i=0;i<base-10;++i) //Generates capital alphabets for bases smaller than 36
digs[i]=i+65;
}
As far as comments go, a comment would be in order when using "71". I assume it's because 71 is 97 - 26, or 'a' - 26. In which case, make life easy and do the replacement.
//Generates alphabetical digits for the given base
void genDigs(int base,char *digs){
if (base>36){ //Because for bases greater than 36,the capital alphabets are not enough
for(int i=0;i<26;++i) //Generates capital alphabets
digs[i]=i+'A';
for(int i=26;i<base-10;++i) //Generates small alphabets
digs[i]=i+'a' - 26;
}
else
for(int i=0;i<base-10;++i) //Generates capital alphabets for bases smaller than 36
digs[i]=i+'A';
}
Maybe a constant for 26 like NUM_LETTERS. Makes the code reading easier.
Generally you'll have a file called BaseConvert.h and a file called BaseConvert.cpp. All the stuff in BaseConvert.h goes in BaseConvert.cpp. Your DECLARATIONS go in BaseConvert.h. Your implementation code goes into BaseConvert.cpp. That's usually the way things are done. Makes linking and including easier.
string Num; //String variable for keeping final form of number
for(int i=0;i<digNum;++i){
if(num[i]<10)//For elemnts smaller than 10,we can use the element itself as digits
Num[i]=num[i]+48;
else
Num[i]=digs[num[i]-10]; //Otherwise it should be replaced by an alphabetical digit
}
Looks like a seg fault just waiting to happen. Use the += operator. Even if it isn't a seg fault, if you're appending a character to the end, the += operator is the way to go.
Num[i] += digs[num[i]-10];
But you've got bigger problems...
char *digs=new char; //An array for
delete [] digs;
I don't see an "array" of chars allocated. I see ONE char allocated. But I see an "array" deleted. And I see a function that expects an array.
I didn't actually run your program. Does it compile? Does it run? Does it crash? Give good results?