>Please tell me why is one of the function defintion working and one is not??
Please define "working" and "not working". The way I see it, your code is not working period, because you don't ever allocate memory to name and then proceed to copy a string to the memory you never allocated. This will likely cause a crash in all cases.