I have a code to convert a number to words(e.g. 31415-->Thirty one thousand four hundred fifteen) The code compiles with no errors/warnings and outputs correctly when debugging. But nothing happens when I 'Run' it. I'm using Code::Blocks. Any help would be appreciated!
Code:
int main (void)
{
int *dataptr = NULL,num,digit_count;
STACK* stack = create();
dataptr = malloc(sizeof(int));
printf("Enter number");
scanf("%d",&num);
while (num!=0)
{
*dataptr = num%10;
num = num/10;
push (stack,dataptr);
digit_count ++;
};
convert (stack,digit_count);
return 0;
}
void convert (STACK* stack,int digit_count)
{
int* datainptr1=NULL,*datainptr2=NULL;
datainptr1 = (int*)pop(stack);
switch (digit_count)
{
case 1: //some function
break;
case 2:
{
if (*datainptr1 == 1)
{
datainptr2 = (int*)pop(stack);
switch (*datainptr2)
{
case 1:printf ("Eleven");
break;
case 2:printf ("Twelve");
break;
case 3:printf ("Thirteen");
break;
case 4:printf ("Fourteen");
break;
case 5:printf ("Fifteen");
break;
case 6:printf ("Sixteen");
break;
case 7:printf ("Seventeen");
break;
case 8:printf ("Eighteen");
break;
case 9:printf ("Nineteen");
break;
}
}
else
{
//more
}
}
break;
}
}
The 'pop' function in a custom header file(for stack simulation) returns a void* by the way. Any ideas on what's wrong?