Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 C


  Preprocessor magic:Default Arguments in C

This post is for programmers who like C or for one reason or another can't use anything else but C in one of their projects. The advantages of having default arguments is not something that needs convincing. It's just very nice and convenient to have them. C++ offers the ability to define them but C under the C99 standard has no way to allow it. In this post I will detail two ways I know of implementing default arguments in C. If a reader happens to know additional ways please share in the commentsSuppose we have a struct that contains some data and we want to initialize it//! The struct we wa...

12,415 0       C PREPROCESSOR DEFAULT ARGUMENTS


  Do you really understand C? 21st International Obfuscated C Code Contest winning entries

The 21st International Obfuscated C Code Contest(IOCCC) officially launched the winning source code. IOCCC requires contestants to write the most creative and the most obfuscated C codes with the size limited to 4kb and less Work of each participant is impressive. The winners, including one French, one Korean, five Americans, one Belgian, one Israeli, one British, four Japanese and one Chinese.Here we list some codes:Best short programSeonghoon Kang  from Korea- Decodes spelled out numberslong long n,u,m,b;main(e,r)char **r;{f\or(;n++||(e=getchar()|32)>=0;b="ynwtsflrabg"[n%=11]-e?...

11,656 0       C OBSFUCATION CONTEST


  Socket programming tips in Solaris

I sponsored a topic in stackoverflow.com, and hoped the programmers can share the socket programming tips in different UNIX flavors. But unfortunately, the responders are few. So I can only share my socket programming tips in Solaris at here (the Chinese version can be found there):1. Use the following link options: "-lresolv -lnsl -lsocket";2. Solaris doesn't provide socket options: SO_SNDTIMEO and SO_RCVTIMEO(Why does Solaris OS define SO_SNDTIMEO and SO_RCVTIMEO socket options in header file which actually not support by kernel?);3. In SCTP programming, must call bind() befor...

11,650 0       C SOCKET SOLARIS


  C program to shutdown or turn off computer

C Program to shutdown your computer :- This program turn off i.e shutdown your computer system. Firstly it will asks you to shutdown your computer if you press 'y' the your computer will shutdown in 30 seconds, system function of "stdlib.h" is used to run an executable file shutdown.exe which is present in C:\WINDOWS\system32 in windows-xp. You can use various options while executing shutdown.exe for example -s option shutdown the computer after 30 seconds, if you wish to shutdown immediately then you can write "shutdown -s -t 0" as an argument to system function. If you wish to restart your c...

11,265 0       CODE WINDOWS C SHUTDOWN COMMAND


  memcpy() vs memmove() in C

memcpy() copies the bytes of data between memory blocks. If the block of memory overlaps, the function might not work properly. Use memmove() to deal with overlapping memory blocks. memmove() is very much like memcpy() but very flexible as it handles overlapping of memory blocks. example : char msg[50] = "abcdefghijklmnopqrstuvwxyz"; char temp[50]; main() { strcpy(temp, msg); printf("Original Msg = %s\n",temp); memcpy(temp+4, temp+16, 10); printf("After memcpy without overlap = %s\n",temp); strcpy(temp , msg); memcpy(temp+6, temp+4, 1...

11,114 0       COMPARISON MEMORY MEMCPY MEMMOVE C DIFFE


  Books for entry level C programmers

In computing, C is a general-purpose programming language initially developed by Dennis Ritchie between 1969 and 1973 at Bell Labs Its design provides constructs that map efficiently to typical machine instructions, and therefore it found lasting use in applications that had formerly been coded in assembly language, most notably system software like the Unix computer operating system.To learn C, we need to read many C books and have many practices. Here we summarize a list of C books which may help you learn C.1. How to Think Like a Computer Scientist :C versionAlthough it contains only basic ...

8,872 0       C BOOK BEGINNING


  An experience of fixing a memory-corruption bug

During the last 4 months, I was disturbed by a memory-corruption bug, and this bug will cause program crash. Until last Monday, I found the root cause and fixed it. This debug process is a difficult but memorable experience, so I will share it in this article. My program works as a SMS Hub. When it receives a SMS, it will allocate a structure in heap memory like this:typedef struct{ ...... int *a[8]; ......} info;After processing the SMS, the program will free the memory, and send the SMS to the next Hub or Operator.  Since last November, the program will crash som...

8,840 0       C UNIX DEBUG SOLARIS MULTI-THREAD


  VIM Plugins for C/C++ developers

Following up on my previous post on Essential Vim Plugins for Web Developers, I have decided to tell you about the awesomeness of the C / C++ plugin for Vim in this article.Now to get things going, let’s start by thinking what are the basic stuffs that you would be carrying out as a C / C++ developer? Include header files, some functions, loops, conditional statements and a main function. These are some repetitive boring tasks that you would rather have someone else do it for you. Well, that’s what c.vim plugin is all about.For example, after installing this plugin, when you...

7,273 0       C PLUGIN C++ DEVELOPER VIM VIM FOR C