943,917 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 14671
  • C RSS
May 8th, 2004
1

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

Expand Post »
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.
Attached Files
File Type: cpp code_sample.cpp (473 Bytes, 34 views)
Similar Threads
Reputation Points: 11
Solved Threads: 0
Newbie Poster
rodkay is offline Offline
10 posts
since May 2004
Jun 19th, 2004
0

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

How exactly do you want to get length?!!
The only way I know of is using <string.h> There is a strlen(char *s) function which return the strings length
Reputation Points: 16
Solved Threads: 0
Light Poster
Fili is offline Offline
34 posts
since Jun 2004
Nov 13th, 2010
-2
Re: Using .length() with multidimensional char array ? (Help)
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();
}
Reputation Points: 12
Solved Threads: 5
Light Poster
ashishkumar008 is offline Offline
45 posts
since Nov 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: trying to create N semaphores
Next Thread in C Forum Timeline: Problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC