struct data_struct* search_in_list(char *val, struct data_struct **prev)
{
char *dat=NULL;
char *dat2=NULL;
struct data_struct *ptr = head;
struct data_struct *tmp = NULL;
bool found = false;
printf("\n Searching the list for value [%s] ...found is.%d\n",val,found);
while(ptr != NULL)
{
printf("\n ptr !=null .....Searching the list for value ");
dat = ptr->val;
dat2 = val;
printf("hello world %s.......%s",dat,dat2);
**if (dat == dat2)
printf("Hello !!!");**
found = (val == ptr->val);
printf("the data is%d",found);
if (found)
{
printf("\n ptr val if......Searching the list for value [%s] ",ptr->val);
found = true;
break;
}
else
{
printf("\n else found....Searching the list for value [%s] ",ptr->val);
tmp = ptr;
ptr = ptr->next;
}
}
if(true == found)
{
ptr = ptr->next;
printf("\n truefound...Searching the list for value [%s] ",ptr->val);
if(prev)
*prev = tmp;
return ptr;
}
else
{
printf("\n Searching the list for value [%s] ",ptr->val);
return NULL;
}
}
以下条件不工作:如果条件和逻辑比较不工作
if (dat == dat2)
printf("Hello !!!");
知道为什么。 如果我比较(“serverip”==“serverip”),这工作正常..
但如果我说(ptr-> val == val).....这不工作......不知道为什么。 我做错了什么......任何guesss ....
'的printf(“世界你好%s的...... 。%s“,dat,dat2);'你在这里得到了什么? –