Quote:
Why this is segmentation fault ?
By your program is done wrong.
The C language is not managed, you have to manually manage memory, and you fail to do it in your program.
strcpy(str,"Hello");
Copies "Hello" to a place you don't own, that is the reason of the segment fault.
You need to learn properly the C language and follow tutos. Knowing the syntax is not enough, there is much more to know.