variable type used for string

what is the variable type used to represent a string? ie an
entire word rather then just a single letter (char)
LVL 1
yaelieAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Answers2000Connect With a Mentor Commented:
an array of chars or a pointer to the start of the string (char *)


/* Array */
char x [] = "Some Text" ;

or

/* Pointer */
char * x = "Some Text" ;

C style strings represent strings terminated with a NUL (character 0)

The standard library includes a type called string which you can use to manipulate stirngs.

MFC (Microsoft Foundation Classes) includes a type called CString which you can also use to manipulate strings
0
 
thresher_sharkCommented:
There is no C++ defined variable for a string.  Perhaps you used to be/are a Basic programmer?  I think there is a string variable in that language.  But in C++ there is not.

You have to use an array of chars.  Here is an example:
char MyString[128] = "Hello world! :-)";

This is the closest you can come to a string.  It may seem overly complicated, but once you get used to it, it's really very easy.  Consider purchasing a book on C++ programming, it would show you all about arrays.

If you want a fairly good, FREE book that you can download off the internet, go to:
http://www.bruceeckel.com/

and download his.  Considering the fact that its free, and still very comprehensive, I highly recommend it.
0
 
thresher_sharkCommented:
Looks like answers2000 beat me to it! :-)
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
yaelieAuthor Commented:
Thank you both for the answers...actually, i'm a pascal programmer shark and thats where i got the string from. I know how to do arrays but was wondering if there was an easier way to do it. Thank you for the url though iI'm going to dl the book now.
0
 
thresher_sharkCommented:
Okay, I suppose that makes sense.  I'm glad I could help!
0
 
thresher_sharkCommented:
Read the above comment in response to:
>> i'm a pascal programmer
:-)
0
All Courses

From novice to tech pro — start learning today.