Below is your code fixed.
Legend
- red: content removed
- green: content added
The Code
#include<>
#include<>
#include <stdio.h>
#include <string.h>
int main()
{
char name, email, pass;
char name[100]; // Strings ("text") is stored in char array or buffers.
char email[100];
char pass[100];
printf("Enter your name: ");
scanf("%c%s", name); // You want to read a whole string (%s), not just a single character (%c)
printf("Enter your email address: ");
scanf("%c%s", email);
printf("Enter password: ");
scanf("%c%s", pass);
if(pass=abcd)
if (strcmp(pass, "abcd") == 0) // strcmp() is used to find any differences between strings. 0 mean no difference.
{
printf("Passoword is correct.");
}
if else // The "if" must not be there.
{
printf("Password is incorrect.");
}
}
References