Hi, I'm pretty new to programming. I'm trying to make a program to determine if input from the user is plural or not, and based on that, print a response with the correct grammar, but it isn't working.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <windows.h>
int main()
{
char name[10];
char food[10];
char *p;
p = (strlen(food)-1);
/*int plural = strlen(food); */
printf("What is your name?\n");
scanf("%s", &name);
printf("Hello %s.\n");
Sleep(1000);
printf("What is your favorite food?\n");
scanf("%s", food);
/* if (food[plural]="s") {
printf("Gross! %s are disgusting!\n");
}
else if (food[plural-1]!="s") {
printf("Gross! %s is disgusting!\n"); I tried this part first and it didnt work so I
.tried the pointers which I dont really
.understand */
}
return 0;
}
Whenever I run the program, no matter how many "s"'s I put in or dont put in, the always returns, "Gross! ___ are disgusting!" What am I doing wrong?
I tried with pointers and with a string length variable (the one that's hidden), but there's probably several ways to do it.