array error

Started by
9 comments, last by Fruny 18 years, 8 months ago
can someone help me, i made an array made of bad words, i declared it string BadWords[]= "(explicit)" if ( name==BadNames[]) //when i put this code, it keeps saying expected primary expression before ']' token, i changed it to if ( name==BadNames[0]) but the program shut off or something, why can't i check to see if name = BadNames[] it won't let me check to see if name is equal to any of the elements in BadNames, i've checked over and over, and tried to see what the prob was
Advertisement
Seriously, this should be the last drop. Someone just complained that this guy was posting too much, so the reply of Mr. Avont29 was the following:

Avont29 Member since: 6/22/2005 From: Richmond, United States
Posted - 8/12/2005 11:42:11 AM oh, ok, sorry about so many posts, i'll keep it down, and i'll fix my code on my own, i don't need your help, heh

Now, take a look of the time of this post...
(EDIT: about 45 mins before this topic was created.)


..also, this is a cross post.


Why not have a serious agreement for people who register, that if they're not serious, they don't belong here. Very often that can even be seen from the first post a person makes. Some people come here to learn and really appreciate the help, some come here and behave like leeches. :(
if this is C/C++ then you will need char in place of string.

ace
Because no one else seems to bite the bullet, I will...

Avont29, you cannot expect these forums to teach you C++. All the recent threads you've started here show that you don't master the language, in the slightest.

The best and only advice we can give you, is for you to buy a decent C++ book, and run through it. You seem to have the energy, in surplus even, so I'm quite sure it wouldnt take you much time to become proficient, and even if you don't have the money, there are many free ebooks and PDFs online.

What you're doing is a waste of yours and our energy. This is the same as banging your head against a door, trying to get it open, because you don't want to take the time to learn how to operate a knob...
Quote:Original post by Caminman
Seriously, this should be the last drop. Someone just complained that this guy was posting too much, so the reply of Mr. Avont29 was the following:

Avont29 Member since: 6/22/2005 From: Richmond, United States
Posted - 8/12/2005 11:42:11 AM
oh, ok, sorry about so many posts, i'll keep it down, and i'll fix my code on my own, i don't need your help, heh

Now, take a look of the time of this post... (also, this is a cross post).


Why not have a serious agreement for people who register, that if they're not serious, they don't belong here. Very often that can even be seen from the first post a person makes. Some people come here to learn and really appreciate the help, some come here and behave like leeches. :(


ok, im sorry, i'll keep the posts, down, im serious this time
You need to compare the array elements one by one, you can't just compare an array of strings with a string.
don't make me rate you down!

...
I don't know why I am even answering this...

The correct way to compare an array against a known value is to iterate through each one and perform a test. So in your example, you would have something like this.

for (int i = 0; i < numArrayItems; i++)
{
if (badWorlds == name)
{
// Do something
}
}
....[size="1"]Brent Gunning
Quote:Original post by pinacolada
don't make me rate you down!

...


Me or the OP? [rolleyes]
Quote:Original post by skittleo
I don't know why I am even answering this...

Because you're a nice person? [grin]
Quote:Original post by Konfusius
Me or the OP? [rolleyes]

Not you [grin]

This topic is closed to new replies.

Advertisement