Posts

Showing posts from November, 2008

GCC Extenstion

GCC has given some additions to its existing functionality. Please find more details from the below link. http://www.ibm.com/developerworks/linux/library/l-gcc-hacks/index.html

About Random numbers!

How to generate Random numbers? We can generate Random numbers by using rand() or random() function. This is defined in "stdlib.h". Example below illustrates to generate Random number. #include < stdio.h > #include < stdlib.h > int main() {     int i;     int num;     int range;          num = random();  // or else use rand()     printf("\nnum : %d", num);     num = random(); // or else use rand()     printf("\nnum : %d", num);          return 0; } But everytime you run this program, it will give same series. Starting number is decided by the seed, which is always initialized by 0 for rand(). If we want a different series, we need to initiate seed value using srand(int). That means, for a particular seed value, we always get one series. srand(int); Good way of initiating seed value is by using time, so that everytime we get different value for seed. See the example below: #include < stdio.h > #include < stdlib.h > #include < tim

What is Code Bloat?

Code bloat refers to the unnecessarily generated code which effects the performance of the program. It makes program run slow and uses unncessary resources. Example for code bloat is using in-line functions for long peice of code. Some naive compilers of C++ will make different function of each type if a template is defined, which causes so much of unnecessary code which is never executed. This un used code is called as dead code.