For starters you should enlarge the array becuase the string literal "Friday"
can not fit into the array.
For example
char n[10];
Secondly instead of scanf
use the standard function fgets
because scanf
such as it is written in your program is unsafe.
For example
fgets( n, sizeof( n ), stdin );
You can remove the trailing new line character the following way
n[ strcspn( n, "\n" ) ] = '\0';
To do that you have to include the header <string.h>
.
In this statement
if(n==s)
there are compared addresses of first characters of the strings. You need to use standard string function strcmp
to compare the strings themselves instead of the pointers. For example
if ( strcmp( n, s ) == 0 )
Here is a demonstrative program
#include <stdio.h>
#include <string.h>
int main(void)
{
const char *s = "Friday";
char day[10];
printf( "Enter a day: " );
fgets( day, sizeof( day ), stdin );
day[ strcspn( day, "\n" ) ] = '\0';
if ( strcmp( day, s ) == 0 )
{
printf( "Have a nice weekend!" );
}
else
{
printf( "Have a nice day!" );
}
return 0;
}
Its output might look like
Enter a day: Friday
Have a nice weekend!