- #1
- 5,199
- 38
Hey everyone!
If I have a function that takes a pointer to char (i.e. char array) as an argument, can I pass a "string literal" (I think that is the right term) as an argument to that function, even if that string hasn't previously been declared anywhere? For example:
Is that allowed? I'm wondering where the memory comes from for the string.
If I have a function that takes a pointer to char (i.e. char array) as an argument, can I pass a "string literal" (I think that is the right term) as an argument to that function, even if that string hasn't previously been declared anywhere? For example:
Code:
void myfunc(char *message)
{
/* function definition goes in here */
}
/*
.
.
.
and then some time later
*/
myfunc("this is my message");
Is that allowed? I'm wondering where the memory comes from for the string.