Connecting Tech Pros Worldwide Help | Site Map

array of char array in headerfile (string list) - some questions

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 05:49 AM
sigi
Guest
 
Posts: n/a
Default array of char array in headerfile (string list) - some questions

i've got something like this in a headerfile:

const char* const StringList[]=
{
"FirstString",
"SecondString",
....
}

(haven't checked the syntax yet, but i guess it's ok?)

there can be more than one such list, later on i decide which to take and
use this to fill a std::map (i also got some defines to make code easier to
read... )

my questions:

is there any way to get number of strings in this list? if they were fixed
length there's the trick using sizeof var / sizeof var[0].

it would be easy to provide a const of values in this list, or having a
special "stop string" - just out of curiosity...

but i guess if there's something i would rather be compiler specific and
therefor this question won't belong here:)




  #2  
Old July 23rd, 2005, 05:49 AM
benben
Guest
 
Posts: n/a
Default Re: array of char array in headerfile (string list) - some questions


"sigi" <sigi_23@yahoo.de> wrote in message
news:1120393094.552767@news.liwest.at...[color=blue]
> i've got something like this in a headerfile:
>
> const char* const StringList[]=
> {
> "FirstString",
> "SecondString",
> ....
> }
>
> (haven't checked the syntax yet, but i guess it's ok?)
>
> there can be more than one such list, later on i decide which to take and
> use this to fill a std::map (i also got some defines to make code easier[/color]
to[color=blue]
> read... )
>
> my questions:
>
> is there any way to get number of strings in this list? if they were fixed
> length there's the trick using sizeof var / sizeof var[0].[/color]

This is indeed the answer.
[color=blue]
>
> it would be easy to provide a const of values in this list, or having a
> special "stop string" - just out of curiosity...[/color]

If this is a question, the answer is, it doesn't matter, up to you.
[color=blue]
>
> but i guess if there's something i would rather be compiler specific and
> therefor this question won't belong here:)
>
>
>[/color]


  #3  
Old July 23rd, 2005, 05:49 AM
Rolf Magnus
Guest
 
Posts: n/a
Default Re: array of char array in headerfile (string list) - some questions

sigi wrote:
[color=blue]
> i've got something like this in a headerfile:
>
> const char* const StringList[]=
> {
> "FirstString",
> "SecondString",
> ....
> }
>
> (haven't checked the syntax yet, but i guess it's ok?)
>
> there can be more than one such list, later on i decide which to take and
> use this to fill a std::map (i also got some defines to make code easier
> to read... )
>
> my questions:
>
> is there any way to get number of strings in this list? if they were fixed
> length there's the trick using sizeof var / sizeof var[0].[/color]

The elements of an array are always fixed length. So this is indeed the way
to find the number of elements.

  #4  
Old July 23rd, 2005, 05:49 AM
sigi
Guest
 
Posts: n/a
Default Re: array of char array in headerfile (string list) - some questions

a my lord, for sure...

thanks.

"Rolf Magnus" <ramagnus@t-online.de> wrote in message
news:da8pji$hi8$01$1@news.t-online.com...[color=blue]
> sigi wrote:
>[color=green]
>> i've got something like this in a headerfile:
>>
>> const char* const StringList[]=
>> {
>> "FirstString",
>> "SecondString",
>> ....
>> }
>>
>> (haven't checked the syntax yet, but i guess it's ok?)
>>
>> there can be more than one such list, later on i decide which to take and
>> use this to fill a std::map (i also got some defines to make code easier
>> to read... )
>>
>> my questions:
>>
>> is there any way to get number of strings in this list? if they were
>> fixed
>> length there's the trick using sizeof var / sizeof var[0].[/color]
>
> The elements of an array are always fixed length. So this is indeed the
> way
> to find the number of elements.
>[/color]


  #5  
Old July 23rd, 2005, 05:49 AM
sigi
Guest
 
Posts: n/a
Default what a dumb question, sorry...


"benben" <benhongh@hotmail.com> wrote in message
news:42c7e6e3$0$20028$afc38c87@news.optusnet.com.a u...[color=blue]
>
> "sigi" <sigi_23@yahoo.de> wrote in message
> news:1120393094.552767@news.liwest.at...[color=green]
>> i've got something like this in a headerfile:
>>
>> const char* const StringList[]=
>> {
>> "FirstString",
>> "SecondString",
>> ....
>> }
>>
>> (haven't checked the syntax yet, but i guess it's ok?)
>>
>> there can be more than one such list, later on i decide which to take and
>> use this to fill a std::map (i also got some defines to make code easier[/color]
> to[color=green]
>> read... )
>>
>> my questions:
>>
>> is there any way to get number of strings in this list? if they were
>> fixed
>> length there's the trick using sizeof var / sizeof var[0].[/color]
>
> This is indeed the answer.
>[color=green]
>>
>> it would be easy to provide a const of values in this list, or having a
>> special "stop string" - just out of curiosity...[/color]
>
> If this is a question, the answer is, it doesn't matter, up to you.
>[color=green]
>>
>> but i guess if there's something i would rather be compiler specific and
>> therefor this question won't belong here:)
>>
>>
>>[/color]
>
>[/color]


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.