devxlogo

Tip Bank

OpenXML for Multiple Trips to the Database

Suppose you need to make multiple inserts (or updates or deletes) to a SQL Server database?for instance, inserting items in a shopping cart. In the past, you needed to loop

Fixed-length Strings Using Templates

Instead of writing a string class that contains a (char *), why not write a string class with a fixed char array? Of course, it would be repetitive if you

A Sparse Array of Any Type with Fast Access

A sparse array saves memory by not allocating memory for elements that are not initialized or to which you don’t need access. They’re quite easy using the STL map.This example

Output Data into a File

Use the following code: #include void main(){ char name[15]; double salary; ofstream outFile(“FileName.txt”, ios::in); while (outFile){ outFile >> name >> salary; }}

Outputting Currencies

How to print out a Currency in Java is an often overlooked topic. How should Currency be printed out in an international, standardized way?The java.text.NumberFormat class is used for outputting

Copy Data from One File to Another

This wrapper class “FileCopier” copies data from one file to another. This class uses another class: “StreamCopier”. /** * Class: FileCopier * Author: Vivek Bagade * Date: 8/31/2001 * Description:

Generate Thumbnails Out of a Larger Image

This is useful in a Web-based Photo Gallery kind of application, where you need to automatically generate multiple sizes of the same image. class ThumbnailGenerator { public void generateThumbnail (String