
-----------------------------------
aliveiswell
Tue Dec 16, 2003 10:52 pm

char
-----------------------------------
I'm a little confused with this because in a tutorial I read it said that this variable will only hold 1 character. If this is true how do I make it hold more, or is there another variable I could use.thanks

-----------------------------------
Tony
Tue Dec 16, 2003 11:17 pm


-----------------------------------
you could ether use character arrays

char letter[10];


or use string

#include

String word;


-----------------------------------
wtd
Mon Feb 09, 2004 11:22 am


-----------------------------------
you could ether use character arrays

char letter[10];


or use string

#include

String word;


Just one comment on this.  The class name is "string".  All lowercase.  Second, it's in the std namespace, so unless you're "using namespace std;", you should fully qualify the name.

#include 

int main()
{
   std::string word;
}

-----------------------------------
Andy
Mon Feb 09, 2004 5:01 pm


-----------------------------------
no... just have using namespace std;
and just declare it by having string str;

-----------------------------------
wtd
Mon Feb 09, 2004 8:19 pm


-----------------------------------
no... just have using namespace std;
and just declare it by having string str;

Yeah, it's convenient, but it's best to use "using namespace" very selectively.

Instead of:

#include 

using namespace std;

int main()
{
   string str;
}

Write something like:

#include 

int main()
{
   using namespace std;

   string str;
}

That way it doesn't affect the entire program.  After all, you might create another class named "string" elsewhere, and using the full name (std::string vs. util::string in a program I was writing today) will help avoid collisions.

-----------------------------------
Andy
Mon Feb 09, 2004 9:15 pm


-----------------------------------
y would u create another string class???

-----------------------------------
Catalyst
Mon Feb 09, 2004 9:36 pm


-----------------------------------
i like

   using std::string;

then only the string name is taken not all  the std ones

-----------------------------------
wtd
Mon Feb 09, 2004 10:09 pm


-----------------------------------
y would u create another string class???

I'm writing a virtual machine interpreter.  The "string" type for the VM is the 32-bit location of the string in memory and its 32-bit length.

-----------------------------------
rizzix
Mon Feb 09, 2004 11:02 pm


-----------------------------------
nice.. those are the things i like doing.. but.. i have no time heh
for what language.. or have u designed ur own language as well ?

i have designed the perfect language in mind.. after looking at Perl, java, c++, obj-c and python
wow you can only imagine the language i have in mind.. (not necessarly bloated like c++ if that what ur thinking, it's more like perfect, well atleast to me)

-----------------------------------
wtd
Mon Feb 09, 2004 11:16 pm


-----------------------------------
I'm writing it in C++.  Templates and the STL really cut down the amount of work I have to do.

I'd love to do it in Obj-C or Eiffel, but Eiffel doesn't have unsigned integer types, and Obj-C doesn't have templates.

And clean C++ (without any C cruft) is actually really nice to develop in.
