Oh OK... now I understood your problem... You are very right in judging the problem and telling that it returns pointer to some static object. Actually that is what the behaviour of ctime is expected to be. See this is from the man page of ctime >>>>
The ctime(), asctime(), gmtime(), and...