I am somewhat new to C programming, but this looks like it should work. I am using MS VS .Net 2002. When I put my mouse over the variable, the strings match up, but when I compare them, the comparison does not equal each other. What I do here is parse a string, then I need to compare it. so if the string is "123 W Main St". It seems to parse ok, but when i come to the "W", I need to compare it with "W" and it does not work.
Code:
char * Grab_String(char* string, int length)
{
char *ip;
int i = 0;
ip = (char *) malloc(length*sizeof(char *));
while (i < length)
{
ip[i] = string[i];
i = i++;
}
ip[i] = '\0';
return ip;
}
char *ParseDelimiter (char *addr_string, char delimiter)
{
char *field;
char hold;
int seperator;
int str_len;
int i = 0;
int x=0;
bool ok=false;
str_len = strlen(addr_string);
while (i <= str_len)
{
if (addr_string[i] == delimiter)
break;
i = i++;
}
field = Grab_String(addr_string, i);
if ("W"==field) //////HERE IS THE CODE THAT DOES NOT WORK
{
ok=true;
}
return field;
}
Thanks for helping.
George