Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: How to passing multidimesional array of string to function?

Reply
Thread Tools

Re: How to passing multidimesional array of string to function?

 
 
Malcolm McLean
Guest
Posts: n/a
 
      07-23-2012
בתאריך יום ש*י,23 ביולי 2012 12:53:29 UTC+1, מאת Alter:
> Hi all
>
>
> How to pass a multidimensional array of string to a function?
>
>
>

void multidstringfunction(char **str, int *dims, int Ndims)
{
int i;
int width = 1;

/* let's print the strings along the major dimension */
assert(Ndims > 1);
/* we don't know how many other dimensions there are, so we've got to
work out the block width */
for(i=1;i<Ndims;i++)
width *= dims[i];

/* now we can get the string at [i, 0, 0, 0 ...] by multiplying
by width */
for(i=0;i<dims[0];i++)
printf("string %d - %s\n", str[i*width];
}

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How to passing multidimesional array of string to function? Varun Tewari C Programming 5 07-29-2012 08:33 AM
Re: How to passing multidimesional array of string to function? Barry Schwarz C Programming 0 07-27-2012 10:05 PM
Re: How to passing multidimesional array of string to function? aftnix C Programming 0 07-26-2012 08:35 PM
Re: How to passing multidimesional array of string to function? Eric Sosman C Programming 8 07-25-2012 12:45 AM
Re: How to passing multidimesional array of string to function? Ben Bacarisse C Programming 0 07-23-2012 01:07 PM



Advertisments