I'm using dev c++ . This is silly program which ask the correct key to show a text. This program working perfectly with type "int" (just numbers):
#include <stdio.h>
#include<conio.h>
main()
{
int key;
printf("This program show a mensage if you get the correct key \n");
printf("Write the key:\n");
scanf("%i",&key);
if(key==1234)
{
printf("Welcome to stackoverflow \n");
}
else
{
printf("You keep going slept \n");
}
getch();
return 0;
}
But How can I replace for strings for example: sesame, house and so on.
I've tried by matrix:
char key[];
However i get Error.
Sincerily NIN.
Update:
I could get a new program :
#include <stdio.h>
#include<conio.h>
main()
{
char key[7]; /*replace int for char*/
printf("This program show a mensage if you get the correct key \n");
printf("Write the key:\n");
scanf("%c",&key);
if(key=="sesame") /*numbers for string*/
{
printf("Welcome to stackoverflow \n");
}
else
{
printf("You keep going slept \n");
}
getch();
return 0;
}
However even though I fix the correct key ("sesame") I just get "You keep going slept"