November 7, 2000

Maximum Number of Characters

Question: I’m reading approximately two million characters into an array. The max number of elements that Borland Turbo C++ 5.02 allows me is not enough. Can I declare this array to be a lot bigger or allocate more memory for this array? Answer: The maximal possible size of an array

Positioning the Cursor

Question: In qbasic there is a command called LOCATE. What it does is locate where you want your output on the screen, eg: locate 1,1: meaning one down and one acorss. Is there a command like that in C++, and what is it? Answer: Standard C++ doesn’t support graphics directly.

Creating a Temporary File

Many applications create temporary files that exist as long as the program is running and are later discarded. For example, a Web browser can store a list of pages that have been viewed during the current browsing session and redisplay them when you press “Back”. The problem is that most

Generating a Unique Filename

To generate a unique filename that won’t conflict with any other files that exist in the current directory, use the tmpnam() function declared in as follows: char * tmpnam(char * name); The function generates a unique name that may contain up to L_tmpnam characters. You can call tmpnam() up to

Designated Initializers

Another new feature in C99 is called designated initializers. Designated initializers enable you to initialize specific array elements without having to initialize the entire array. For example, suppose you have an array of five elements and you want to initialize only its second and fourth elements, while leaving the remaining

Reading Strings that Contain White Spaces

The std::getline() functions reads data from an input stream and writes it to a string object. Unlike cin’s >> operator, getline() also reads white spaces, which makes it useful for reading strings that contain blanks. For example: #include #include int main(){ std::string name; cout

Changing the Endian-ness of a Number

Suppose you receive an int from a remote host and you wish to convert it to big-endian order. Here is another portable solution for handling of big and littleendian data formatting. This solution is based on the use of the right shift operator: // big endianint to_big_endian(int d){ unsigned char

Optimize Your Pages For Users’ Screen Resolution

You can never tell just what your users are going to do. Sometimes, their browser settings aren’t quite optimal for your site, and you are forced to cater to the lowest common denominator. For instance, if you have a lot of data to display, it would be great to take

Send Emails From an Oracle Stored Procedure

The following code is for those who need to receive e-mails from the database to report a correct ending backup, a corrupted backup, a database fail, or any message database/admin related.The code is based on the UTL_SMTP package supplied in Oracle8i V8.1.6 (release 2).First step: Installing necessary JAVA classes, they

No more posts to show