some functions

M

MC felon

I heard that the operators for string manipulations have been
overloaded in standard c++.
like for strcmp, we use == and for assignment, we use =. is it true?
also, what are the function equivalents in standard c++ for:
1.) clrscr(); //clear the screen
2.) gotoxy(int x_axis,int y_axis); // go to position in screen at x
axis and y axis
 
J

Jacek Dziedzic

MC said:
I heard that the operators for string manipulations have been
overloaded in standard c++.
like for strcmp, we use == and for assignment, we use =. is it true?

Almost, just the other way round. For "==" _you_ use strcmp
and for assignment ("=") _you_ use strcpy. :>

Trust me -- with C++ strings it is much harder to shoot yourself
in the foot than with C arrays of characters.
also, what are the function equivalents in standard c++ for:
1.) clrscr(); //clear the screen
2.) gotoxy(int x_axis,int y_axis); // go to position in screen at x
axis and y axis

There are none, AFAIR. Usually the platform you run your programs
on gives you a platform-specific means to do it, like "conio.h".
Might as well use them in C++.

HTH,
- J.
 
S

Salt_Peter

MC said:
I heard that the operators for string manipulations have been
overloaded in standard c++.
like for strcmp, we use == and for assignment, we use =. is it true?
also, what are the function equivalents in standard c++ for:
1.) clrscr(); //clear the screen
2.) gotoxy(int x_axis,int y_axis); // go to position in screen at x
axis and y axis

The std::string is a versatile class with many member functions and
operator overloads.
Overloading operators with any class is a C++ cornerstone.

[15.20] How can I clear the screen? Is there something like clrscr()?
http://www.parashift.com/c++-faq-lite/input-output.html

C++ doesn't rely on a screen to be available at all. If it did it
probably wouldn't be portable. While that might seem like a restriction
to you, its one of its strong points. C++ code doesn't confine itself
to any particular graphical user interface (or platform) although some
cross-platform GUI libraries are available.
 
E

eriwik

I heard that the operators for string manipulations have been
overloaded in standard c++.
like for strcmp, we use == and for assignment, we use =. is it true?

Yes, but the really nice thing is the concatenation operator +, I can
concatenate strings together without having to worry about buffer
overflows and stuff like that and with a nice syntax:

std::string str = "Hello";
str += " World!";
 
G

Gavin Deane

MC said:
I heard that the operators for string manipulations have been
overloaded in standard c++.

You've heard that? It's certianly true, but if you want to become
proficient in C++ you need to be learning more efficiently than just
hearing about the occasional feature. You need a good textbook or two.

This is ideal if you have some programming experience
http://www.acceleratedcpp.com/

And this is an excellent reference for the standard library, including
(but by no means limited to) std::string
http://www.josuttis.com/libbook/

Gavin Deane
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,296
Latest member
HeikeHolli

Latest Threads

Top