Firstly, the program is wrong because size is an uninitialised non-const variable from which you are trying to create an array of characters. Neither does the programmer nor the computer know what size the array is. Technically, the computer does but forget about that because size is a variable holding some junk value and for all you know, it might be -29348 or something. Your compiler will flag that as an issue as long as you haven't suppressed warnings. Don't create arrays of unknown length.

Secondly, think for a minute why you may need to know the size from the user. Let's say you need to maintain a record of names. Every name doesn't have the same size. So, in practice, you allot a fixed size and tell the user that "max size you can enter is X".

Fourthly, what you need is a good C/C++ book that explains all of this step by step.

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook, The Wizardry Compiled