[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

how to declare a 2-dimensional version of strlen

Posted on 2013-01-09
4
Medium Priority
?
250 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
Suggested Courses

650 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