hi there,
the code below is supposed to check the response typed from keyboard and perform an action based on that. but the if statements never evaluates to zero even when the correct response is entered. what am i doing wrong?
thanks in advance.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream.h>
int main()
{
char temp, ch;
int value;
printf("please confirm(y/n):");
scanf("%c", &temp);
strcpy(&ch,strlwr(&temp));
printf("%c\n", ch);
value = strcmp("y", &ch);
printf("comp result= %d\n ", value);
if ((strcmp("y", &ch)) == 0)
{
printf("confirmed\n");
exit(99);
}
else
if ((strcmp("n", &ch)) == 0)
{
printf("declined\n");
exit(99);
}
else
printf("invalid choice (y/n)\n");
return(0);
}