In borland do I need to use the command line? Or can I get an IDE? And with strings, is that the only way to compare chars? Thx?
In borland do I need to use the command line? Or can I get an IDE? And with strings, is that the only way to compare chars? Thx?
Stan The Man. Beatles fan
When I was a child,
I spoke as a child,
I thought as a child,
I reasoned as a child.
When I became a man,
I put childish ways behind me"
(the holy bible, Paul, in his first letter to the Cor. 13:11)
How do you mean you need strings to compare chars?
Thats bull
I know I can compare single chars but how do I compare an array of chars. Example:
char a[50]="greenhouse";
char b;
cout << "Enter greenhouse \n";
cin >> b;
if (b==a)
{
cout << "very good \n";
}
else
{
cout << "wrong \n";
}
.... // other stuff
Stan The Man. Beatles fan
When I was a child,
I spoke as a child,
I thought as a child,
I reasoned as a child.
When I became a man,
I put childish ways behind me"
(the holy bible, Paul, in his first letter to the Cor. 13:11)
Try....
In cstringCode:if(strcmp(compare this, and this)) { // }
I am against the teaching of evolution in schools. I am also against widespread
literacy and the refrigeration of food.
You'll want to read up on the standard string functions. For example "strcmp" is used to compare (case sensitive) for exact string matches.
strcmp( astring, bstring );
Quzah.
Hope is the first step on the road to disappointment.
Explain more or give me a site I can go to. (though I still think strings are easier!)
What would be the upside of using char over string?
Stan The Man. Beatles fan
When I was a child,
I spoke as a child,
I thought as a child,
I reasoned as a child.
When I became a man,
I put childish ways behind me"
(the holy bible, Paul, in his first letter to the Cor. 13:11)
You can manipulate strings more, and you can have whitespace in strings.Originally posted by Stan100
What would be the upside of using char over string?
Oh, and I think strcmp returns false if the strings match, so maybe you'd want to use the ! operator
Last edited by abrege; 12-17-2002 at 05:10 PM.
I am against the teaching of evolution in schools. I am also against widespread
literacy and the refrigeration of food.
The free Borland compiler is command line only.
[\EDIT]
Of course, you can write a DOS batch file and click on it to compile. I've done that when writing long programs and I've gotten tired of typing the same command line over and over.
Some editors can invoke compilers too, but I've never used that feature.
[EDIT\]
Last edited by DougDbug; 12-17-2002 at 05:32 PM.
I like strings, but why would I use chars instead?
Stan The Man. Beatles fan
When I was a child,
I spoke as a child,
I thought as a child,
I reasoned as a child.
When I became a man,
I put childish ways behind me"
(the holy bible, Paul, in his first letter to the Cor. 13:11)
I read your question wrong You can output chars more easily, and in some situations it is just unnecessary to use strings.
I am against the teaching of evolution in schools. I am also against widespread
literacy and the refrigeration of food.
By way of information, a 'string' is a char array. Specialized, meaning more functional, but it's still a char array.
Research the member functions of the 'string' class (basic_string) to see what all is available to you. I'd venture to say that the majority of the members of this Board have never, nor will ever, make use of the full functionality that the 'string' class affords you.
We're weaned on traditional char arrays and are led, erroneously, to feel that using strings is akin to "cheating".
I can see this attitude in an academic setting where some value can be placed on learning the foundations of the language, but , beyond that..."Prefer string operations to C-style string functions." Bjarne Stroustrup
Now, before I get jumped all over and beaten badly - which I would look upon with disdain - there may, certainly, be situations where using chars may be preferred over strings. Can't think of any, at this moment, but...
-Skipper
"When the only tool you own is a hammer, every problem begins to resemble a nail." Abraham Maslow