Calling a function with a literal list of strings?
- From: Joakim Hove <joakim.hove@xxxxxxxxx>
- Date: Tue, 31 Jul 2007 07:39:26 -0000
Hello,
I have a function like this:
/* It actually does something else .... */
void func (int size, const char ** string_list) {
int i;
for (i=0; i < size; i++)
printf("String number %d: %s \n",i,string_list[i]);
}
And would like to (be able) to call it with a literal list of strings,
something like:
func(3 , {"String1" , "Hello", "The last string ..."});
Is that possible? I have tried various casts like (const char **),
(const char [3][]) and (const char [3]*) but to no avail. I am using
gcc with std=gnu99, i.e. I am more than happy to accept C99 features.
Thank you - Joakim Hove
.
- Follow-Ups:
- Re: Calling a function with a literal list of strings?
- From: Chris Torek
- Re: Calling a function with a literal list of strings?
- Prev by Date: Re: printf
- Next by Date: Re: printf
- Previous by thread: Declaring variables in "case" blocks?
- Next by thread: Re: Calling a function with a literal list of strings?
- Index(es):
Relevant Pages
|