1. Originally Posted by JDGATX
You didn't change what they told you to change. Start there.
ey ? what you mean

2. Code:
`(!strcmp`
get rid of the red

3. Originally Posted by vart
Code:
`(!strcmp`
get rid of the red
yes i have done that and well i have been fiddling around n well now i am tottally confussed of wat sympols to use ect ect atm
Code:
```    for(x = 0; x < sizeof(cities) / sizeof(*cities); x ++)
{
if(strcmp(cities[x], pos[i])){point[i] = x;} // assigns point a number depends what place name was enterd
if(strcmp(cities[x], pos[i])) {flag=1;}
}
if(flag==0)
{
printf("\n Invalid place name please re enter: ");
i--;
wrong=1;
}```
i have just that atm and just trying differnt symbols like ==0 ==1 >0 <0 ectect im just confussed

4. Go check the documentation for the return of strcmp. Don't guess!

5. all i could find is how to initialize strcmp and well the outcome
Code:
```
Negative if s1 is less than s2.
Zero if s1 and s2 are equal.
Positive if s1 is greater than s2```
i still dont understand lol can anyone link me somthing so i can understand this stuff its been haunting me for a few days now

6. Originally Posted by fortune2k
all i could find is how to initialize strcmp and well the outcome
Code:
```
Negative if s1 is less than s2.
Zero if s1 and s2 are equal.
Positive if s1 is greater than s2```
i still dont understand lol can anyone link me somthing so i can understand this stuff its been haunting me for a few days now
yes http://cboard.cprogramming.com/showp...&postcount=148

7. Code:
```Negative if s1 is less than s2.
Zero if s1 and s2 are equal.
Positive if s1 is greater than s2```
What's the problem? I think both the doc and vart is clear. The answer has been handed to you several times.

8. Originally Posted by vart
you do not need it here

Code:
```if(strcmp(...) == 0)
{
/* strings match */
}```
or

Code:
```if(strcmp(...) != 0)
{
/* strings do not match */
}```
depending on what you need
doesnt workkkk
Code:
``` if(strcmp(cities[x], pos[i])==0){point[i] = x;}
if(strcmp(cities[x], pos[i])!=0) {flag=1;}```
i get no error message no point output

9. Originally Posted by fortune2k
doesnt workkkk
Code:
``` if(strcmp(cities[x], pos[i])==0){point[i] = x;}
if(strcmp(cities[x], pos[i])!=0) {flag=1;}```
i get no error message
So when you say "doesn't work" and "i get no error message", what do you expect to happen (that is the "works" I suppose), and how is that different when you say "doesn't work". The above is correct code for point[i] being set to x when pos[i] matches cities[x], and flag will be set to one if pos[i] is not equal to cities[x] - of course, if that's a direct copy of the code, I would prefer:

Code:
``` if(strcmp(cities[x], pos[i])==0)
{
point[i] = x;
} else {
flag=1;
}```
Edit: to clarify - if you have already tested that if the two strings are equal, comparing them again to see if they are "not equal" doesn't make much sense - we already know that. And strcmp() can be quite an expensive operation if the strings are nearly equal and long, so it's good practice to not do comparisons when they are not needed.

Edit2: Having read your code again, I think it looks like flag should be set to 1 when you have found the city, not the other way around. So perhaps what you really want is:
Code:
``` if(strcmp(cities[x], pos[i])==0)
{
point[i] = x;
flag=1;
}```
Your code as it stands would always set flag = 1 at some point, because there's only at most one city name that matches, and all others will be a non-match - so you probably want set the flag ONLY when you have a match.
--
Mats

10. The code works, but the logic is all wrong. Think about what you're doing. When does flag need to be set? Perhaps you should rename it to something better, such as bNotFound or bFound or something like that.

11. i found the problem it was that
Code:
`    const char *cities[] = {"London", "Glasgow", "Birmingham",	"Manchester", "Luton", "Poole", "Stafford", "Stoke", "Cardiff", "Derby"};`
is staticly set and not in the right orderi need to gather that info from the txt file i cant have nothing statically set i may have to do somthing with the array places[11] because that gets all the place names how would i set this

12. Elysia, I see that you are a Programming MASTER! Congrats! Now it's time for you to set up an appointment with your counselor to learn to be more patient with people. This forum is a very very helpful tool. It's filled with people’s challenges & questions. Either you contribute to the solutions, like I know you do in many cases or simply opt out and keep YOUR opinions of peoples short comings, errors, or mistakes to yourself. Keep all your posts as factual as possible. I'm sure everyone will love you for it! It's important to keep people positive in c programming!

Yes first post, but one all in here want to see.
ROCK

13. When the post is the 160th of the thread, it shows quite a bit of patience, I would say.

--
Mats

14. anyone know how i can have this constructor gather the info from text file or place array

15. Originally Posted by fortune2k
anyone know how i can have this constructor gather the info from text file or place array