|
|
|
C++ newbie question
Posted by diegoeskryptic [send private reply] at March 27, 2002, 03:04:26 PM
Here I go again........... can someone tell me the difference between a string variable and a string literal?
Posted by taubz [send private reply] at March 27, 2002, 05:08:08 PM
A string variable is a variable which holds a string. For instance,
dim s as String ' s is a string variable A string literal is something in the code itself which the interpreter or compiler evaluates to a string. For instance, s = "ABCDEFG" ' "ABCDEFG" is the string literal, but s is the string variable In general, a literal is something (literal=written) in the code. For instance, in (x = 6.023), 6.023 is a numeric literal. - taubz
Posted by CodeRed [send private reply] at March 27, 2002, 05:50:31 PM
If your learning strings you should learn how to use char pointers as well. Strings (in C++) can be declared 3 different ways (that I know of). One is a character array, like this: char name[3] = {'B','o','b'}; Two is to use the string class in string.h like this: String name = "Bob"; and the third is to use a pointer like this: char* name = "Bob";
Posted by Psion [send private reply] at March 27, 2002, 05:50:53 PM
The subject says C++, and you still use Basic? :-)
Posted by diegoeskryptic [send private reply] at March 27, 2002, 06:03:48 PM
ahhhhhhh... what the heck... thanx
Posted by CodeRed [send private reply] at March 28, 2002, 11:43:12 AM
Oh that's what you mean by "dim s"
Posted by taubz [send private reply] at March 29, 2002, 12:02:32 AM
I didn't mean for my comment to be taken so literally. :) (But it could be VB.NET.)
Register as a new user | |||||||||||