#81046
01/30/2002 10:04 PM
|
Joined: May 2001
Posts: 1,042 Likes: 7
Moderator
|
Moderator
Joined: May 2001
Posts: 1,042 Likes: 7 |
The other programming forums don't include this language, so i'm hoping this is the right board once again... Is there any data types that can store letters/words? Here's my problem. I'm trying to create a function to print out stuff. quote: #include
void print(int printme);
int main() { print(this); }
void print(int printme) { cout << printme << endl; }
But using integer or floating data types require numbers.
Help? 
|
|
|
#81047
01/30/2002 10:14 PM
|
Joined: May 2001
Posts: 2
Junior Member
|
Junior Member
Joined: May 2001
Posts: 2 |
Howdy,
Try either looking into the string.h header file or use an array of chars (the way I learned to do strings).
Let me know if that helps. Matt.
|
|
|
#81048
01/30/2002 10:14 PM
|
Joined: Nov 2001
Posts: 436
Member
|
Member
Joined: Nov 2001
Posts: 436 |
Jeez, that seems so complicated to print something. I prefer: echo "this"; ?> Or even: this  Not a C++ guru myself, sorry.
|
|
|
#81049
01/30/2002 10:54 PM
|
Joined: May 2001
Posts: 1,042 Likes: 7
Moderator
|
Moderator
Joined: May 2001
Posts: 1,042 Likes: 7 |
I'll give string.h a shot, tho i only though oostring.h was the only string header. Like for.. quote: #include #include "oostring.h"
int main() { int len; oostring MyString; MyString = "Print Me";
len = MyString.length();
cout << MyString << endl << "Length = " << len << endl; return 0; }
For which oostring.h only messes with the text itself. I'll have to try it out tomorrow morning if we have school(it's been snowing hard, so i don't know for sure).
BTW, wrong language Bloogerman , if it were only that easy... 
|
|
|
#81050
01/30/2002 11:53 PM
|
Joined: Nov 2001
Posts: 436
Member
|
Member
Joined: Nov 2001
Posts: 436 |
Yeah, I know, I was saying that PHP is a lot easier than C++, although they both have different powers.
|
|
|
#81051
01/31/2002 6:52 AM
|
Joined: Dec 2000
Posts: 595
Member
|
Member
Joined: Dec 2000
Posts: 595 |
quote: #include
#define STRING 'nonono' void print();
int main() { STRING = 'nanana'; print(); }
void print() { cout << STRING << endl; }
:D ?
|
|
|
#81052
01/31/2002 7:25 AM
|
Joined: Mar 2001
Posts: 7,394
Admin / Code Breaker
|
Admin / Code Breaker
Joined: Mar 2001
Posts: 7,394 |
[code][/code]Doesn't it work?
|
|
|
#81053
01/31/2002 8:30 AM
|
Joined: May 2001
Posts: 1,042 Likes: 7
Moderator
|
Moderator
Joined: May 2001
Posts: 1,042 Likes: 7 |
Sorry, snow day today again  , oh wait..j/k  , so there's no way for me to test them out till tomorrow, if there's not another snow day.
|
|
|
#81054
01/31/2002 5:23 PM
|
Joined: Nov 2001
Posts: 198
Member
|
Member
Joined: Nov 2001
Posts: 198 |
use sprintf to print formatted numbers etc. to a string... it works in the same way as printf
Just another boring 17-year-old and yes, I like smilies/graemlins
|
|
|
Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.
Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
|
|
Posts: 449
Joined: February 2008
|
|
Forums63
Topics37,575
Posts293,930
Members13,823
|
Most Online6,139 Sep 21st, 2024
|
|
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
|
|
|
|