Size of String Tables

B

Blei Stift

I want to go through a string table (char **str). Every string in it
has a different size. My idea for getting the size was size =
sizeof(str)/sizeof(str[0]). But this doesn't work.

- Blei Stift
 
S

Seebs

I want to go through a string table (char **str). Every string in it
has a different size. My idea for getting the size was size =
sizeof(str)/sizeof(str[0]). But this doesn't work.

Right, because sizeof(char *) is the size of a pointer, not the number of
things pointed to.

You can use strlen() to figure out how long strings are, if these are
actually strings (null-terminated sequences of characters), otherwise,
you are sorta lost -- you can't find out how large an array is just from
a pointer to its first element.

-s
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,954
Messages
2,570,114
Members
46,702
Latest member
VernitaGow

Latest Threads

Top