In C, If i am given a char array that takes in char values from the user....how
ID: 3733770 • Letter: I
Question
In C, If i am given a char array that takes in char values from the user....how would I convert that char array into a string array and send it to a function that takes string as arguments?
For example Suppose the char named "line" has the following elements " Convert me into strings " is sent by the user.
How would i convert that into char *string? and send it to a function push( char * string) that takes strings? If i have stated something wrong...please correct me and answer in the correct version Thanks!
Explanation / Answer
So you have a char array
line which contains "Convert me to string" and
you need to pass it to a function
push(char *string)
You don't have to do any conversion, a character array can be easily passed to the
function having an argument of type char * because internally line is a
pointer pointing to the first character of "Convert me to string".
So you can call the function as :
push(line);