?
Solved

how to declare a 2-dimensional version of strlen

Posted on 2013-01-09
4
Medium Priority
?
261 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
2 Comments
 
LVL 31

Accepted Solution

by:
Zoppo earned 2000 total points
ID: 38761941
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
ID: 38768600
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
Suggested Courses

862 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