I have made this program, It get the users adress, name and work. Then It puts it all into one string and outputs that string. (I know there are better ways to do this)
Your logic is sound, the issue is that when you declare a char array of size 10, you don't actually get 10 spots to put characters in, you only get nine. The last one is reserved to signify the end of the string. [Here ][1] is a reference is you would like to read up more on the issue:
Just declare one character more than the number you want. There are many excellent tips on how to flush the stream, ignore the rest of the line, etc that you can use as well.
Good luck!