954,124 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Using .length() with multidimensional char array ? (Help)

Hi all,

Quite a basic question for most of you; I am trying to obtain length of a string < char name[MAX_ENTRIES][MAX_NAME_SIZE] > for use in a for loop that will perform isalpha.

for (int j=0; j < &name[i].length(); j++)

I am getting error 2228: left of '.length' must have class/struct/union type upon compile.

Can anyone please offer me some guidance?

This is a simple win32 console application. See attached code.

Attachments code_sample.cpp (0.46KB)
rodkay
Newbie Poster
10 posts since May 2004
Reputation Points: 11
Solved Threads: 0
 

How exactly do you want to get length?!!
The only way I know of is using There is a strlen(char *s) function which return the strings length :D

Fili
Light Poster
34 posts since Jun 2004
Reputation Points: 16
Solved Threads: 0
 

rodkay, actually I can help you in c#. In c# you can use GetLength() to get multi dimensional array. Use like this:


for (int j = 0; j < myjaggedarraymutidim[i].GetLength(0); j++)
{
for (int k = 0; k < myjaggedarraymutidim[i].GetLength(1); k++)
{
Console.Write(" "+myjaggedarraymutidim[i][j, k]+" ");
}

Console.WriteLine();
}

ashishkumar008
Light Poster
45 posts since Nov 2009
Reputation Points: 12
Solved Threads: 5
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You