Why this code is not running? Why str1 is not assigned to str2 ?? I know i have an option of using strcpy but i wish to know the reason why this is not working??
str2 is a static array. You can't just reassign it like a pointer.
As for your pointer example, q=s reassigns q to point to the same space that s is pointing to. However, the pointer reassignment does not copy the value.
For static arrays, use strcpy() to copy the value. For pointers, use strdup().