Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

variable type used for string

Posted on 1998-10-03
6
Medium Priority
?
203 Views
Last Modified: 2010-04-01
what is the variable type used to represent a string? ie an
entire word rather then just a single letter (char)
0
Comment
Question by:yaelie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 8

Accepted Solution

by:
Answers2000 earned 150 total points
ID: 1174312
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
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1174313
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
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1174314
Looks like answers2000 beat me to it! :-)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 1

Author Comment

by:yaelie
ID: 1174315
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
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1174316
Okay, I suppose that makes sense.  I'm glad I could help!
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1174317
Read the above comment in response to:
>> i'm a pascal programmer
:-)
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question