simple if/else statement (produces wrong value)

How do I get this if/else statement to work properly?

when you enter a name between 'p' and 's' it should send you to room 2432 but no matter what value you enter it says you can get your tickets here.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23


#include <stdio.h>

main()
{
	
	char name[25];
	printf("What is your last name? ");
	printf("(Please capitalize the first letter!)\n");
	scanf_s(" %s", name);
	
	if ((name[0] >= 'P') && (name[0] <= 'S'))
	{
		printf("You must go to room 2432 for your tickets\n ");
	}
	else
	{
		printf("You can get your tickets here.\n");
	}

	return 0;
}
Look at line 11, you are reading a space into the string before reading the actual name

Change that line to:
scanf_s("%s", name);
Topic archived. No new replies allowed.