Previous Thread
Next Thread
Print Thread
Rate Thread
#81046 01/30/2002 10:04 PM
Joined: May 2001
Posts: 1,042
Likes: 7
Moderator
Moderator
Offline
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? shocked

Sponsored Links
#81047 01/30/2002 10:14 PM
Joined: May 2001
Posts: 2
Junior Member
Junior Member
Offline
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
Offline
Joined: Nov 2001
Posts: 436
Jeez, that seems so complicated to print something.

I prefer:
echo "this";
?>

Or even:

this

tipsy Not a C++ guru myself, sorry.

#81049 01/30/2002 10:54 PM
Joined: May 2001
Posts: 1,042
Likes: 7
Moderator
Moderator
Offline
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 tipsy , if it were only that easy... shocked

#81050 01/30/2002 11:53 PM
Joined: Nov 2001
Posts: 436
Member
Member
Offline
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.

Sponsored Links
#81051 01/31/2002 6:52 AM
Joined: Dec 2000
Posts: 595
Member
Member
Offline
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
LK Offline
Admin / Code Breaker
Admin / Code Breaker
Offline
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
Offline
Joined: May 2001
Posts: 1,042
Likes: 7
Sorry, snow day today again mad , oh wait..j/k laugh , 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
Offline
Joined: Nov 2001
Posts: 198
use sprintf to print formatted numbers etc. to a string... smile
it works in the same way as printf


Just another boring 17-year-old
and yes, I like smilies/graemlins

Link Copied to Clipboard
Donate Today!
Donate via PayPal

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.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)