I'm trying to get ready for an exam for my year one programming course. I need my if statement to return a sum with the number of characters before the user enters a 'p' or 'P' in a 10 character string. However, I can't seem to get it to count properly.
for (int i=0;i<=strlen(toProcess);i++){
if (toProcess[i]!='p'|| toProcess[i]!='P'){
sum=sum+1;
printf("%c ", toProcess[i]);
}
}
Aucun commentaire:
Enregistrer un commentaire