Possible Duplicate:
C - Difference between “char var[]” and “char *var”?
I have written the following C code
#include<stdio.h>
int main()
{
char name[31];
char *temp;
int i ;
scanf("%s",name);
temp = name;
name = temp;
}
I got the following error when compiling
incompatible types when assigning to type 'char[31]' from type 'char *'
Array name
is a pointer to first element(here char pointer ..right?). right? The above code means that character array and char*
are different types ..Is it true?
Why is the type of name != char *
?
Why can I assign another char
pointer to a char
pointer (the name
array)?