This is a C app for finding numbers from base 10 to bases 2-16. Here is the code:
\#include "stdio.h" //With the code font, it wouldn't show stdio.h if I put it in less or greater than signs
int main(void)
{
const char baseDigits[16] ={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
int convertedNumber[64];
long int numberToConvert;
int nextDigit, base, index = 0;
_Bool keep_going = 1;
//get number and base
while(keep_going)
{
printf("Number to be converted?\n");
scanf("%ld", &numberToConvert);
printf("base to convert to (2-16)?\n");
scanf("%i", &base);
do {
convertedNumber[index] = numberToConvert % base;
index++;
numberToConvert = numberToConvert / base;
}
while(numberToConvert != 0);
for(--index; index >= 0; --index){
nextDigit = convertedNumber[index];
printf("%c", baseDigits[nextDigit]);
}
return 0;
}
When I try to compile it, Dev-C++ says that the last line of code, the closing brace for main, is an error. The exact wording is "In function main: Syntax error at end of input". Any suggestions? And no hate speech about C or Dev-C++, either.
asked
Oct 16 '10 at 12:49
HHBones
4.1k●61●82●118