How would I go about putting a single line of user inputted characters into an array ?
Example...
User inputs:
Then I want an array of say987654321
x[10]
x[0] will be 9
x[1] will be 8
I'm really more stuck at the part of what to do with the user input... If I could atleast get it as one big chunk I could iterate it or something... It seems like I'm overlooking something basic in doing this but... I've tried using scanf_s to put it into an array e.g.
Output from the above gives:Code:int main (void) { char x[81]={'\0'}; printf("Type your #s here:\n"); scanf_s("%c", &x); printf("Element 0: %c\n", x[0]); printf("Element 1: %c\n", x[1]); printf("Element 2: %c\n", x[2]); }
So the first thing is being input I believe, but how can I get the entire thing?Type your #s here:
987654321
Element 0: 9
Element 1:
Element 2:
Press any key to continue . . .