Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 char
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
aliveiswell




PostPosted: 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
Sponsor
sponsor
Tony




PostPosted: Tue Dec 16, 2003 11:17 pm   Post subject: (No subject)

you could ether use character arrays
code:

char letter[10];


or use string
code:

#include<string.h>

String word;
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
wtd




PostPosted: Mon Feb 09, 2004 11:22 am   Post subject: (No subject)

tony wrote:
you could ether use character arrays
code:

char letter[10];


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




PostPosted: 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




PostPosted: 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




PostPosted: Mon Feb 09, 2004 9:15 pm   Post subject: (No subject)

y would u create another string class???
Catalyst




PostPosted: Mon Feb 09, 2004 9:36 pm   Post subject: (No subject)

i like
code:

   using std::string;

then only the string name is taken not all the std ones
wtd




PostPosted: 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
Sponsor
sponsor
rizzix




PostPosted: 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




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: