Solved

how to declare a 2-dimensional version of strlen

Posted on 2013-01-09
4
196 Views
Last Modified: 2015-05-28
I need to know how to write a declaration, including arguments and result, for a 2-dimensional version of strlen (that is, a function that receives an array of points to char and an array size of size_t integers, and an int that specifies the number of elements in each array.
Not sure if this is correct but I have:  

2dimstrlen(char **pointers, size_t *integers, int number)

can you verify if this is correct?
0
Comment
Question by:rnformatix
4 Comments
 
LVL 30

Accepted Solution

by:
Zoppo earned 500 total points
Comment Utility
Hi rnformatix,

you just want to know if the function signature is correct? If so I'd say mostly: You pass an array of strings as pointer to char pointers, you pass an array to size_t as pointer and you pass the number of elements as int.

One wrong thing is the function name. Function names must not start with a number, so you should rename it to something like strlen2dim or something.

Another thing is you need to declare a return type, i.e. void. So it should look somehow like this:

void strlen2dim( char **pointers, size_t *integers, int number );

Hope that helps,

ZOPPO
0
 
LVL 13

Expert Comment

by:Hugh McCurdy
Comment Utility
Based on the information provided, it appears that Zoppo's advice is good.

I think, however that you should have a non-void return type.  The return type could indicate if there was an error or not.  One error is that you passed null for one of the pointers.  (Although another option is to make sure the program crashes but you might want the crash to be more graceful then the default.)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now