Solved

how to declare a 2-dimensional version of strlen

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

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…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
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 how to use strings and some functions related to them in the C programming language.

831 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