954,496 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

What can a string hold?

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 "/\|;:'>

tmantix
Newbie Poster
10 posts since Jun 2009
Reputation Points: 10
Solved Threads: 0
 

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 = "\""

sfuo
Practically a Master Poster
656 posts since Jul 2009
Reputation Points: 164
Solved Threads: 99
 

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.

tmantix
Newbie Poster
10 posts since Jun 2009
Reputation Points: 10
Solved Threads: 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 = "_"

ixmike88
Junior Poster in Training
54 posts since Sep 2010
Reputation Points: 9
Solved Threads: 4
 

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.

tmantix
Newbie Poster
10 posts since Jun 2009
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: