A char holds ONE character. An array of chars (a string) holds more (as many as you specify). Strings, and indeed ALL arrays cannot be compared like:
if(a == b) ...etc.
The strcmp() function returns 0 if two strings match, non-zero otherwise...
Code:
#include <stdio.h>
char* name(void);
int Identical(char a[], b[] ) { return strcmp(a, b) ? 0 : 1 }
int main()
{
char nam[100];
printf("What is your name?\n");
scanf("%s",&nam);
if ( !Identical(nam, name() ) )
{
printf("No your name is not %s\n",nam);
printf("Your name is %s \n",name());
}
else
{
printf("I know you, %s!\n", name() );
}
system("PAUSE"); //..edit: you may need this too :)
return 0;
}
char *name(void)
{
char nick[] = "****y";
return nick;
}