I am stuck on this program. I have to get 3 numbers as strings;convert them to integers,reverse there order,then use tokenization to separate them. I can't seem to get the numbers reversed to begin qwith. Any help would be great! Thanks!
Code:
#include <stdio.h>
#include<string.h>
#include<stdlib.h>
int convertNum ( const char *);
main()
{
char myString[10];
char myString2[10];
char myString3[10];
char myStringfull[80];
int x;
void reverse (const char * const);
printf("Enter a three digit number:\n ");
scanf("%s",&myString);
printf("Enter another three digit number:\n");
scanf("%s",&myString2);
printf("Enter one more number:\n");
scanf("%s",&myString3);
strcpy(myStringfull,myString);
strcpy(myStringfull,myString2);
strcpy(myStringfull,myString3);
x=convertNum(myStringfull);
return 0;
}
int convertNum (const char * myStringfull)
{
int y;
reverse(myStringfull);
y= atoi(myStringfull);
return y;
}
void reverse (const char * const sPtr)
{
if (sPtr[0] == '\0')
return;
else
{
reverse(&sPtr[1]);
putchar(sPtr[0]);
}
}
[code][/code]tagged by Salem