Author |
Message |
aliveiswell
|
Posted: Tue Dec 16, 2003 10:52 pm Post subject: 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 |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Tue Dec 16, 2003 11:17 pm Post subject: (No subject) |
|
|
you could ether use character arrays
or use string
code: |
#include<string.h>
String word;
|
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
wtd
|
Posted: Mon Feb 09, 2004 11:22 am Post subject: (No subject) |
|
|
tony wrote: you could ether use character arrays
or use string
code: |
#include<string.h>
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.
code: | #include <string>
int main()
{
std::string word;
} |
|
|
|
|
|
|
Andy
|
Posted: Mon Feb 09, 2004 5:01 pm Post subject: (No subject) |
|
|
no... just have using namespace std;
and just declare it by having string str; |
|
|
|
|
|
wtd
|
Posted: Mon Feb 09, 2004 8:19 pm Post subject: (No subject) |
|
|
dodge_tomahawk wrote: 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:
code: | #include <string>
using namespace std;
int main()
{
string str;
} |
Write something like:
code: | #include <string>
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
|
Posted: Mon Feb 09, 2004 9:15 pm Post subject: (No subject) |
|
|
y would u create another string class??? |
|
|
|
|
|
Catalyst
|
Posted: Mon Feb 09, 2004 9:36 pm Post subject: (No subject) |
|
|
i like
then only the string name is taken not all the std ones |
|
|
|
|
|
wtd
|
Posted: Mon Feb 09, 2004 10:09 pm Post subject: (No subject) |
|
|
dodge_tomahawk wrote: 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. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
rizzix
|
Posted: Mon Feb 09, 2004 11:02 pm Post subject: (No subject) |
|
|
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
|
Posted: Mon Feb 09, 2004 11:16 pm Post subject: (No subject) |
|
|
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. |
|
|
|
|
|
|