Could anyone check out this code and give me a hint of what I'm doing wrong? I'm trying to make a code that has the user enter a number 1-7, and it displays a day corresponding to that number. For example, 1 = sunday, 2 = monday, etc. Strings are kind of confusing to me right now, so I'm not sure if I'm really far off or close. If anyone has any recommendations on a good string tutorial that would be nice
When I run this, it asks the user for a number, but regardless of what number I put in, even if it's between 1 and 7, it displays the 'else' statement.
Thanks!
Code:
#include <stdio.h>
#include <string.h>
void main()
{
char *nameOfDay[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
int i;
printf("Please enter a number 1 through 7 that corresponds to a day of the week.\n");
scanf("%d", &nameOfDay);
if(i <= 1 && i >= 7)
{printf("%s", nameOfDay[i]);}
else
{printf("You have entered an incorrect number, please run the program again and enter a number 1 through 7.\n");}
}