consider the code
#include int main(void) { char* a; scanf(\"%s\",a);//&a and &a[0] give same results-crashes printf(\"%s\",
In the first example a is a "dangling pointer" - it's a pointer that contains the address of a somewhat random memory location. In most cases accessing this address will result in a crash. Bottom line: you need to allocate memory for a.