Originally Posted by
BeNNs
okay im having some problems taking a whole number from input say 1234 and spliting it up in to individuality numbers and then storing them in a variable. For example i though i could do something like this
Code:
int numberinputbyuser;
int numberarray [5];
scanf("%d"numberinputbyuser);
strcpy(numberarray ,numberinputbyuser);
and maby that will alow me to refrence each part of the numbers inputed from say array space 0 would be 1 and number 1 would be 2 so on but i dont think it works like that. either way some help would be great
Code:
char x[10];
int y;
scanf(" %9s", x);
printf("The digits are...");
for (y = 0; y < strlen(x); y++)
{ x[y] -= '0';
printf(" %d", x[y]); }
printf("\n\nthe third digit is %d", x[3]);
If you know they are all single digit numbers, you can convert them from ascii and use them as actual numbers in your program.