How to pass string to function in c?
A) By passing the string directly as an argument.
B) By passing a pointer to the string as an argument.
C) By using the str()
function to pass the string.
D) By using the string
keyword to pass the string.
Answer:
B) By passing a pointer to the string as an argument.
Explanation:
In C, strings are typically represented as character arrays, and you can pass them to functions by passing a pointer to the character array (string) as an argument. This allows the function to work with and manipulate the string data.