I have a problem, im wanting to type in a value, but the value needs to be limited in size.
the only way i have found to limit the size of the string you enter is by useing "keypress = getch()" in a loop etc.... but this needs a char array (string) in order for it to work.
im wanting to convert this string to an integer, so i enter the value: 1234, the program will convert it and display it in the integer as the number 1 thousand 2 hundrad and thirty four.
if this makes sence
i have had a g at doing this, but i still have no look, there must be a better way or even a way that accually works:
Code:#include <stdio.h> #include <conio.h> void main() { int test1; char *test2 char test3; test3 = getch(); //Get a character, the //user enters a number char strcat(test2,test3); //Concatinate the number to //the end of the string test1 = atoi(test2); //Conver string to integer printf("A%dA",test1); printf("\n\n\n\n\n\n\n\nPress any key to continue...."); getch(); }



LinkBack URL
About LinkBacks




