stuck in array and string compare with strcmp c why ist it working?? compiler got stuck at if(strcmp(c,ch[i]) == 0){
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
char ch[]="asdfghjkl";
char c;
int n=sizeof(ch)/sizeof(char);
scanf("%c",&c);
for(int i=0;i<n;i++){
if(strcmp(c,ch[i]) == 0){
printf("%c is in %d\n",c,i+1);
break;
}else if(i==n-1){
printf("%c not fond\n",c);
}
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire