I am studying for a C++ exam and the study guide says "Be able to initialize arrays using literal arrays." Ok then, so I think well yeah that is easy, a literal array is something like.....Wait, I have no idea what a literal array is! From what I can find (on the web) a "literal" is a constant and whose values are implied by their representations. I got that from this website: http://cpp.comsci.us/etymology/literals.html

This is still on clear to me, what is a literal? What is a literal array? What is the significance of a literal array? I would really like to be clear on this before I go in for my exam. Could someone please point me in the right direction.


10 Years
Discussion Span
Last Post by Squeeker

A literal is a string of characters inside quotes. For example char str[] = "Hello World"; In the above, "Hello World" is considered the literal.


ARGH! A literal string is just a C-String. Curse you silly vernacular! Thanks for the help Ancient, as always you are awesome.


When using the term string literal, yes that is correct.

integers can also have literals. Example: int x = 123; In that the value 123 is a literal, sometimes called magic number or constant value.


> What is a literal array?
Edward's guess is that a literal array is supposed to be an initialization list:

int x[] = { 1, 2, 3, 4, 5 };
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.