Difference between two styles of declaration [Archive] - C Board

PDA

View Full Version : Difference between two styles of declaration


chaser
07-27-2002, 07:20 PM
With c++ you can use strings.h (or sting.h on some people's computers) to allow you to create string variables with much more ease than a char array of 255 chars.

When including strings.h you can...

string mystring;

very simply, and testing is simply If(mystring=="mystring")

As opposed to

char mystring[255];

where testing is done by: If(strcmp(mystring,"mystring")==0)


Are there any downs to using the first way? Isn't it more logical? =)

The Dog
07-27-2002, 07:23 PM
use the first method

RpiMatty
07-27-2002, 07:59 PM
Yes the string class is more logical.
The other way you mention is how programmers created strings before C++. There were no classes to hide all the data and methods in.
I use the string class most of the time.

chaser
07-27-2002, 10:02 PM
When you type it, it's not a ide keyword, or whatever. So it's black and not blue when typed, correct? Shouldn't matter?

Coder
07-28-2002, 10:12 AM
Chaser, I've noticed that you're posting about non game-related issues lately. These posts should go to the C/C++ board.

Thanks