jeudi 2 février 2017

C - if statement issue with &&

So i have this if statement thats boggling my mind, i dont understand why its doing this. Basically it looks like this.

len = strlen(output);

if(len = 4 && stuff){
  printf(4);
}
if(len = 8 && stuff){
  printf(8);
}

If len is = 4 it will still execute the printf(8), same as if len = 8 it will still execute the printf(4).

I was under the assumption with the && if one is false it skips that if statement. Please help this is driving me nuts lol. :) thanks and have a great day!

Aucun commentaire:

Enregistrer un commentaire