String array as parameter

F

Fred

Hello

I have an array defined as

char sArray[5][20] = {""};

then I do :
strcpy(sArray[0], "Text1");
strcpy(sArray[1], "Text2");
....

How can I pass this array to a function, to print it for example?

I tried function(char* pArray[]) but it doesn't work...
 
B

Ben Bacarisse

Fred said:
I have an array defined as

char sArray[5][20] = {""};

then I do :
strcpy(sArray[0], "Text1");
strcpy(sArray[1], "Text2");
...

How can I pass this array to a function, to print it for example?

I tried function(char* pArray[]) but it doesn't work...

Have a look at http://c-faq.com/aryptr/pass2dary.html from the
comp.lang.c FAQ.

You may end up with more questions than answers, but that's fine --
any future questions you ask here will be of a more specific sort.
 
F

Fred

Ben Bacarisse a écrit :
Fred said:
I have an array defined as
char sArray[5][20] = {""};
then I do :
strcpy(sArray[0], "Text1");
strcpy(sArray[1], "Text2");
...
How can I pass this array to a function, to print it for example?
I tried function(char* pArray[]) but it doesn't work...
Have a look at http://c-faq.com/aryptr/pass2dary.html from the
comp.lang.c FAQ.

You may end up with more questions than answers, but that's fine --
any future questions you ask here will be of a more specific sort.

Thanks, it works.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top