s is allocated inside the function and will not exist after the function has returned, so in main() you get a dangling pointer. There are several ways to solve this. One way is to dynamic allocate the array char* s = newchar[100];[100];
The while loop condition should probably be while(a != 0) because otherwise you ignore the last digit.
line 8 is also not correct. The char '0' is not the same as the int 0. You just need to add the value of '0' to the digit value to make it correct: s[i] = '0' + (a%10);
When you print the string on line 21 you should remove the * or otherwise you will only print the first char in the string.
The random characters are because you are not null terminating the string which is needed for knowing when the string ends. s[i] = '\0'; after the loop should fix it.
The digits are in the reverse order. You can either come up with a way to add the digits in the opposite order or reverse the final string.