UBB.Dev
Posted By: Brett C++ Q - 01/31/2002 5:04 AM
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
Posted By: navdlom Re: C++ Q - 01/31/2002 5:14 AM
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.
Posted By: BloggerMan Re: C++ Q - 01/31/2002 5:14 AM
Jeez, that seems so complicated to print something.

I prefer:
echo "this";
?>

Or even:

this

tipsy Not a C++ guru myself, sorry.
Posted By: Brett Re: C++ Q - 01/31/2002 5:54 AM
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
Posted By: BloggerMan Re: C++ Q - 01/31/2002 6:53 AM
Yeah, I know, I was saying that PHP is a lot easier than C++, although they both have different powers.
Posted By: CopyCat Re: C++ Q - 01/31/2002 1:52 PM
quote:
#include

#define STRING 'nonono'
void print();

int main() {
STRING = 'nanana';
print();
}

void print() {
cout << STRING << endl;
}

:D ?
Posted By: LK Re: C++ Q - 01/31/2002 2:25 PM
[code][/code]Doesn't it work?
Posted By: Brett Re: C++ Q - 01/31/2002 3:30 PM
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.
Posted By: pumpkin Re: C++ Q - 02/01/2002 12:23 AM
use sprintf to print formatted numbers etc. to a string... smile
it works in the same way as printf
© UBB.Developers