Hi all,
I have a strange problem occuring when i declare an array of strings in
ANSI C style:
if i have something like :
struct blabla {
//...
char *names[] = {"name1","name2", "name3" };
};
, it doesn't work. But if i declare it by itself (not in a struct - i.e
for instance in the outmost scope of any function) , it works. What am
i doing wrong? Thanks a lot. 6 7143
"todorov" <at*******@gmail.com> writes: I have a strange problem occuring when i declare an array of strings in ANSI C style:
if i have something like :
struct blabla {
//... char *names[] = {"name1","name2", "name3" };
};
, it doesn't work. But if i declare it by itself (not in a struct - i.e for instance in the outmost scope of any function) , it works. What am i doing wrong? Thanks a lot.
A struct member declaration can't include an initializer.
You can initialize a struct member as part of the initializer for a
struct object.
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
"todorov" <at*******@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com... Hi all,
I have a strange problem occuring when i declare an array of strings in ANSI C style:
if i have something like :
struct blabla {
//... char *names[] = {"name1","name2", "name3" };
};
, it doesn't work. But if i declare it by itself (not in a struct - i.e for instance in the outmost scope of any function) , it works. What am i doing wrong? Thanks a lot.
struct blabla {
char *names[3];
} bla = {{"name1", "name2", "name3"}};
-Mike
todorov a écrit : struct blabla {
//... char *names[] = {"name1","name2", "name3" };
};
Wrong way. Try this :
struct blabla {
//...
char *names[] = {"name1","name2", "name3" };
}
=
{
//... ,
{"name1", "name2", "name3"},
};
--
A+
Emmanuel Delahaye
todorov a écrit : struct blabla {
//... char *names[] = {"name1","name2", "name3" };
};
Wrong way. Try this :
struct blabla {
//...
char **names;
}
=
{
//... ,
{"name1", "name2", "name3"},
};
--
A+
Emmanuel Delahaye
Emmanuel Delahaye wrote: todorov a écrit :
struct blabla {
//... char *names[] = {"name1","name2", "name3" };
};
Wrong way. Try this :
struct blabla { //... char **names;
You can't initialise a scalar with more than one element. This should be
char *names[3];
}
The name of the object you are declaring is missing.
= { //... , {"name1", "name2", "name3"}, };
--
Simon.
On 6 Dec 2005 04:46:36 -0800, "todorov" <at*******@gmail.com> wrote: Hi all,
I have a strange problem occuring when i declare an array of strings in ANSI C style:
if i have something like :
struct blabla {
//... char *names[] = {"name1","name2", "name3" };
};
, it doesn't work. But if i declare it by itself (not in a struct - i.e for instance in the outmost scope of any function) , it works. What am i doing wrong? Thanks a lot.
That is not an array of strings. It is an array of pointers.
<<Remove the del for email>> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Gordon Airport |
last post by:
Has anyone suggested introducing a mutable string type (yes, of course)
and distinguishing them from standard strings by the quote type - single
or double? As far as I know ' and " are currently...
|
by: Klaus Neuner |
last post by:
Hello,
I need a function that converts a list into a set of regexes. Like so:
string_list =
print string_list2regexes(string_list)
This should return something like:
|
by: Timothy Babytch |
last post by:
Hi all.
I have a list that looks like , , ]
I try to make it flat one:
How can I archieve such an effect with list comprehension?
Two cycles did the job, but that way did not look pythonic.....
|
by: David. E. Goble |
last post by:
Hi all;
I need to build a list of strings in one function and use the list in
another function.
ie
buildlist(char list, FILE **infile);
{
int i;
|
by: Someone |
last post by:
I wish to use a sorted list to store lists of strings. I am unsure as to
how things work. I want to do something like:
SortedList list = new SortedList();
for(...loop for string...) {
if( !...
|
by: Tripper |
last post by:
Which is the better way to go and why?
//trivial example
List<string> strings = GetStrings();
foreach (string s in strings)
{
// some operation;
}
strings.ForEach(
|
by: Jimp |
last post by:
Why can't I cast List<MyObject> to ICollection<IMyObject>.
MyObject implements IMyObject, and of course, List implements
ICollection.
Thanks
|
by: Paul |
last post by:
Hi,
I feel I'm going around circles on this one and would appreciate some other
points of view.
From a design / encapsulation point of view, what's the best practise for
returning a private...
|
by: dmp |
last post by:
What are Linked list? Please somebody show some ready made programs of
linked list
|
by: dudeja.rajat |
last post by:
Hi,
How to check if something is a list or a dictionary or just a string?
Eg:
for item in self.__libVerDict.itervalues():
self.cbAnalysisLibVersion(END, item)
where __libVerDict is a...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
| |