As i know, i can create an array with item inside such as:
char *test1[3]= {\"arrtest\",\"ao\", \"123\"};
but how can i store my input into arr
Use a 2-dimensional array char input[3][10];
or
an array of char
pointers (like char *input[3];
) which should be allocated memory dynamically before any value is saved at those locations.
First Case, take input values as scanf("%s", input[0]);
, similarly for input[1]
and input[2]
. Remember you can store a string of max size 10
(including '\0'
character) in each input[i]
.
In second case, get input the same way as above, but allocate memory to each pointer input[i]
using malloc
before. Here you have flexibility of size for each string.