0

Hey,

This is probably a newb question, but what all can a string type variable hold?

Is it restricted to just letters or can it hold things like "/\|;:'><!@#$%^"...?

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by tmantix
1

An easy way to think of a string is that its an array of characters in C and a vector of characters in C++.

Meaning it can hold any character. If you want something like " ' or \ in it you need to put an escape character before it like
mystring = "\\"
mystring = "\""

Edited by sfuo: n/a

0

Ok,

What if it is reading from a file? Does the escape character still need to be there?

It probably does, I just would like to make sure. Also how to you get an underscore character?

Thanks in advance,
Tmantix.

Edited by tmantix: n/a

0

http://www.gillius.org/ctut/app_a.htm

you only need escape characters for a few specific characters because these characters are also key characters for the compiler

an underscore would just be mystring = "_"

Thanks,

The link was very handy.

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.