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:) 4 1778
"sigi" <si*****@yahoo.de> wrote in message
news:11***************@news.liwest.at... 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].
This is indeed the answer. it would be easy to provide a const of values in this list, or having a special "stop string" - just out of curiosity...
If this is a question, the answer is, it doesn't matter, up to you. but i guess if there's something i would rather be compiler specific and therefor this question won't belong here:)
sigi wrote: 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].
The elements of an array are always fixed length. So this is indeed the way
to find the number of elements.
a my lord, for sure...
thanks.
"Rolf Magnus" <ra******@t-online.de> wrote in message
news:da*************@news.t-online.com... sigi wrote:
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].
The elements of an array are always fixed length. So this is indeed the way to find the number of elements.
"benben" <be******@hotmail.com> wrote in message
news:42***********************@news.optusnet.com.a u... "sigi" <si*****@yahoo.de> wrote in message news:11***************@news.liwest.at... 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].
This is indeed the answer.
it would be easy to provide a const of values in this list, or having a special "stop string" - just out of curiosity...
If this is a question, the answer is, it doesn't matter, up to you.
but i guess if there's something i would rather be compiler specific and therefor this question won't belong here:)
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: techie |
last post by:
I'm creating a class BookType that will store information about books. Each
book type can have up to 4 authors.
I defined a new type for an array of char:
typedef char array4_t;
This will...
|
by: hokieghal99 |
last post by:
I wish to place all files and directories that are within a user defined
path (on a Linux x86 PC) into some type of array and then examine those
items for the existence of certain charaters such as...
|
by: Gerald |
last post by:
I have a problem with an array of pointers.
In a program I'm writing, I have to read a file, containing thousands
of short lines. The content of another file will be compared against
each line...
|
by: Peter B. Steiger |
last post by:
The latest project in my ongoing quest to evolve my brain from Pascal to C
is a simple word game that involves stringing together random lists of
words. In the Pascal version the whole array was...
|
by: Petter Reinholdtsen |
last post by:
Is the code fragment 'char a = ("a");' valid ANSI C? The
problematic part is '("a")'. I am sure 'char a = "a";' is valid
ANSI C, but I am more unsure if it is allowed to place () around the...
|
by: s.subbarayan |
last post by:
Dear all,
I encountered the following piece of program:
#include <stdio.h>
void strprint(char *str);
void main()
{
char *spr="hello";
strprint(spr);
}
|
by: junky_fellow |
last post by:
Consider an array.
char arr;
When we find sizeof(arr) ---> Output is 10, arr is treated as
an object of 10 chars.
When we say arr+1, ---> arr is treated as a pointer to char.
Why is...
|
by: valerio |
last post by:
Hello all
I would like to dinamically allocate an array of array of structures.
To explain this:
struct file{ char* fileName,int inode) myfiles;
struct file{ char* fileName,int inode) mydirs;
...
|
by: Bill |
last post by:
Hi experts,
I'm trying to return a char from a function. How would this be
setup and what would the declaration look like?
Thanks,
Bill
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |