devxlogo

April 22, 1998

External file execution

Question: How can I code a Visual C++ program that will execute a DOS bat file? Or any other executable file, for that matter? Answer: Use the system() function. This

Quick sort

Question: I have pseudocode for a quick sort. I know how to implement it in Pascal. Is there simple code for quick sort in C++? How can I find other

C++ equivilant of Basic MID$

Question: I need to test for a certain char in a char array.For example, in BASIC I would have: if mid$(string,1,1) = “`” then blah blah blah…. How would I

Performance—C vs C++

Question: What are the performance tradeoffs of using C++ instead of C? Are there any ways of overcoming these tradeoffs? Answer: In general, C++ is every bit as efficient as

Integer lengths

Question: What function gives the actual length of an integer or long integer? For instance, 8 is 1 long, 12345 is 5 long, etc. Answer: Use the sizeof() operator to

Return type _Cdecl

Question: I have seen that in many of the header files in C++ the return type is _Cdecl. For example, in complex.h, we have the following: friend complex _Cdecl acos(complex&)

Sorting in a ListView

Question: I would like to know how to program a Custom Sort procedure on a ListView in Borland’s C++ Builder. Answer: Normally, the ListView control will sort items automatically for

Adding to the front of an array

Question: I have to read in integers and be able to add them to the front of the array. How do I do this? Answer: You can either use the

Pointers to member functions

Question: I am having lots of trouble calling a class member function pointer that is declared within the same class. So far the following compiles: class testClass {public: void (testClass::*ptr)();