1

In my code I have separate function to set string elements through a function to the breakerOptions[] array."time" is one of the string stored in that array

char * breakerOptions[6];
......
int i=0;

while (i<6){
    breakerOptions[i]=(char *)malloc(10);
    strcpy(breakerOptions[i],FILE_BREAKER_OPTION_ARRAY[i]);
    i++;
}

if (breakerOptions[1]=="time"){
    printf("\nYeah first\n");
}

But the thing is that if condition's fails for no reason Then I put a printf to check if it's stored.

printf("\nYeah first,%s %d\n",breakerOptions[1],(int)sizeof(breakerOptions[1]))

even thought its there it doesn't work. I also checked the size of breakerOptions[1]. It gives me 8.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Laksith
  • 354
  • 3
  • 20
  • ah. `breakerOptions[1] = "15468";` `if (breakerOptions[1]=="15468"){` `printf("\nYeah first\n");` `}` but this works. ? – Laksith Sep 18 '15 at 10:11

0 Answers0