Best Web Hosting


COUPON CODE:  techpulpdeal



and get $9.94 off on all hosting plans

Search


There are hundreds of cool tips and tricks. Just search the site below.


Browse articles of 2010 | 2009 | 2008



Category ‘C/C++’

« 1 2 3

  • TECHPULP | How to resolve “Address already in use” error with bind system call
    To get rid of “Address already in use” error with bind system call, SO_REUSEADDR socket option should be set before invoking bind. This makes operating system to allow the socket to bind if there is no active socket bound to...
  • TECHPULP | Find local IP address and local port number using getsockname
    The getsockname function can be used to find the local port used by a given socket. It is valid to use this function only if the socket is already using a local port number. i.e A server socket which invoked...

  • TECHPULP | Find peer IP address and port number using getpeername
    The getpeername function can be used to retrieve the peer IP address and port number on a given socket. For this to work, the socket should have a valid TCP connection established. Typically this is used by server to find...
  • TECHPULP | Print first N characters of a string using printf
    #include <stdio.h> int main(int argc, char *argv[]) { char *p = "My Name is Neo"; printf("First 5 bytes of string is '%.5s'\n", p); return 0; } Result [neo@techpulp ex]# gcc example.c -o example [neo@techpulp ex]# ./example First 5 bytes of...

  • TECHPULP | Strip unused/dead functions from Linux application
    ELF executable can be opimized for size by removing unused or dead functions. The options -ffunction-sections -Wl,–gc-sections can be used to do that. Let us practically verify it using the following C file which has a function named dead_one...
  • TECHPULP | Stack of a Running Process in Unix/Linux
    The command pstack can be used to view the stack trace of a running process. Let us select a running process. [neo@techpulp ~]# ps -e | grep konqueror 22937 pts/5 00:00:17 konqueror Run pstack command with PID of the process....

  • TECHPULP | ELF Binary Optimization for size
    The following steps help in reducing the size of a Linux application ELF binary. These operations can be used for application binary as well as shared library. Use compiler optimization flags -Os (optimize for size) -O2 While linking, try to...
  • TECHPULP | Parse words in a string
    This function requires an array of character pointers words of size maxWords. Note that the input string line supplied to this function will be modified (precisely placing NULL termination character at each word boundary). Alternately the function can be modified...

« 1 2 3

  • Best Ever Deal on Earth