| Ammo (4) | |
|
Hi, I wrote a simple program that takes a users information and displays it back to the user. For my char arrays I ran a forloop and initialized them to blank spaces(" "). I know that you can also initialize to ('\n') or NULL. I just wanted to know what is the best option to use. Iv tested my program over and over again with special characters, blank spaces ect. Its display everything the way it should. I just wanted to know what is safer to use. Thank you, Ammo | |
|
|
|
| Moschops (5959) | |
| The safer option is to use C++ string objects. | |
|
|
|
| Framework (3116) | |||||
That's assignment, my friend. Initialisation is giving a variable/object a value during a declaration context. You can initialise an array by using a brace-enclosed initialiser-list:
See here: http://www.cplusplus.com/doc/tutorial/arrays/ Wazzak | |||||
|
Last edited on
|
|||||
| Peter87 (3687) | |||
No this initialize the first element to 'a' and the rest of the elements to '\0'. | |||
|
|
|||
| Framework (3116) | |
|
Ah -- I'm slipping. I've Edited my post. Wazzak | |
|
Last edited on
|
|