Solved

how to declare a 2-dimensional version of strlen

Posted on 2013-01-09
4
228 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 500 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

726 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