Writing a DLL in C++

Many people incorrectly think the C and C++ languages are the same. Although C++ evolved from C and C++ compilers can compile C, the functionality of the two languages is different. C++ is a complete object-oriented language. It supports inheritance, information hiding, polymorphism and operator overloading. C does not have these features. C++ was originally implemented as a pre-processor to a standard C compiler. The pre-processor parsed the C++ source code and generated C source. [Read More]

C++ STL: Iterators and Containers

This article was contributed by Eric Sanchez Environment: ANSI C++ As one explores further into the standard template library, there must be a basic understanding of a few trivial terms. Perhaps the two most important are containers and iterators. Container Classes As the name implies, instances of container classes are objects that “contain” other objects. C++ STL comes with a rich set of such components that aid in storing collection of values. [Read More]

BWT (Burrows Wheeler Transform) Encoding Algorithm

Encoding Procedure for implementing the algorithm: 1. Select a block size to be used. Block size is directly related to effectiveness of encoding and inversely related to the time required. Hence a compromise has to be reached. 2. Convert the data byte stream to blocks of n bytes where n is the block size chosen. 3. The following example illustrates the procedure to be done next. Let n=6 and the first string be “kerala”. [Read More]

Socket Programming In C

Today we will discuss about Sockets programming paradigm, elements of Sockets applications, and the Sockets API. The Sockets API allows to develop applications that communicate over a network. The network can be a local private network or the public Internet. An important item about Sockets programming is that it’s neither operating system specific nor language specific. Sockets applications can be written in the Ruby scripting language on a GNU/Linux host or in C on an embedded controller. [Read More]

Memory Management Basics

Memory is central to the operation of a modern computer System. Memory consists of a large array of words or bytes each with its own address. The CPU fetches instructions from memory according to the value of the program counter. These instructions may cause additional loading from and storing to specific memory addresses. I have discussed a typical instruction-execution cycle in the previous article. In this article I will discuss on basic hardware issues, the binding of symbolic memory addresses to actual physical addresses and distinguishing between logical and physical addresses. [Read More]

Memory Management In C and C + +

For simple applications, it’s enough just to rely on automatic memory management through local variables. But once the data become larger, it is no longer imperative to request memory from the heap and manage. Content Function Families Allocators Toolbox Smart Pointer STL Containers A function families In principle, belong to the memory always two parts. First, an area of memory are requested, and second, the memory used at the end of the work be returned. [Read More]

Finding time of execution of code in c

#include <time.h\>  

clock_t start;
clock_t diff;
clock_t end;

start= clock();
various algorithm;
end = clock();

diff = end - start;
print diff;

Reducing the space for LCS lengths

When you’ve run out of main memory, any estimate of runtime based on big-O analysis becomes useless. The system either crashes or thrashes, paging in virtual memory. By contrast, if we can reduce the memory required by a program, the time analysis should still hold — we never have to page in more time. Once you’ve watched the dynamic programming solution a few times, you’ll realise that the LCS lengths (the numbers in the grid) are computed row by row, with each row only depending on the row above. [Read More]

Reading from file or Reading integers from file

#include
#include
#include
#include

using namespace std;

int main() {
    int sum = 0;
    int x;
    ifstream inFile;

    inFile.open(“integers.txt”); // read integers from text file
    if (!inFile) {
        cout « “Unable to open file”;
        exit(0); // terminate with error
    }

while (inFile » x) {
        sum = sum+x;
    }
    inFile.close();

cout « “Sum = " « sum « endl;
    return 0;
}