This program will return the IP address of a specified network interface. Use the –ip parameter to get the IP. For example, this will show the IP address of an ethernet interface: ./a.out –ip eth0. #include <stdio.h> #include <string.h> /* for strncpy */ #include <unistd.h> // for close #include <sys/types.h> #include <sys/socket.h> #include <sys/ioctl.h> #include …

This is a simple random number example in C. This will print a random number from 1 – 64. #include <stdio.h> #include <stdlib.h>   int main (void) {   srand(time(NULL)); int r = rand() % 64;   printf("Random INT: %i\n", r);   return 0; }#include <stdio.h> #include <stdlib.h> int main (void) { srand(time(NULL)); int r …

How to define a string and print it out with the printf() function. #include <stdio.h>   /* Defining a global string. */   #define hi "Hello Sire."   int main(void) { /* Printing out the string. */ printf("%s\n", hi);   return 0; }#include <stdio.h> /* Defining a global string. */ #define hi "Hello Sire." int …

This is a very simple Hello World program that you can write in C. int main (void) { write (1, “Hello World\n”, 14); return 0; } Just compile the program like this: [email protected] ~/Documents $ cc my.c -o hello Then execute it to get the output. This is very easy. [email protected] ~/Documents $ ./hello Hello …

This code sample will render a spiral on your terminal when you compile and execute it. Very interesting indeed. #include <sstream> #include <iostream> #include <string> std::string rle = "32 [email protected] 1n16 [email protected] [email protected] 1n13 [email protected] [email protected] [email protected] 1n10 [email protected] [email protected] [email protected] 1n7 [email protected] [email protected] [email protected] " "1n6 [email protected] [email protected] [email protected] [email protected] 1n4 [email protected] [email protected] [email protected]

This code prints out a tick sign using asterisks. I tested this code on Fedora 19 and gcc 4.8 and it compiles without any problems. #include <iostream> #include <iomanip> using std::cout; int main() { cout<<std::setw(8)<<"*"<<"n"; cout<<std::setw(7)<<"*"<<"n"; cout<<std::setw(6)<<"*"<<"n"; cout<<"* *"<<"n"<<"* *"<<"n"<<"*"; cout<< "n"; return 0; } This is what you should get when you compile and …

  http://gentoomen.org/tutorials/resources.html. The gentoomen.org resources page. Very good list of links to various tutorials and help pages. http://tldp.org/LDP/abs/html/. The Advanced BASH scripting guide. ftp://ftp.vim.org/pub/vim/doc/book/vimbook-OPL.pdf. The VIM guideboook. http://stommel.tamu.edu/~baum/programming.html. 3000 useful guides to programming and Linux documentation and help pages. http://samizdat.mines.edu/howto/HowToBeAProgrammer.html. How to be a programmer. A short but comprehensive summary. http://www.psychocats.net/ubuntu/index. Ubuntu resources page. Everything …

This code sample shows how we are wrapping a printf() statement onto multiple lines using backslashes. #include “stdio.h” #define hello “Hello World.” int main(int argc, char* argv[]) { printf(“This is a very long sentence we are handing down\n”\ “Mr smith, do you have anything to say for yourself”\ “?”); printf(“%s\n”, hello); return 0; } This …

A very obfuscated C program. typedef unsigned char t;t*F="%c",l[]="|\\/=_ \n](.\0(),*(.(=(}*.)[[*.",N=’\n’,* r;typedef(*H)();extern H Ar;Q(a){return(a|-a)>>31;}H S(c,a){return(H)(a&~c|(int )Ar&c);}extern t*ist;V(t*u){*u^=*u&2^(*u>>7)*185;}Z(t*u,t n){*u-=n;}e(t c,H h){ R(h,Q(* r^c));} I(){r=l +7-4*Q( getchar ()^*l); }R(H h, int c){Ar=S (c,h);- main() ;}P(){r ++;}z() { O(&N);} O(t*c){ printf( F,+*c); }T(){r= "This is not a function\n" ;}w(U){ U=Z(r,8 ); r-=~Q(* r/8-4); return 0; }M(){r= ist-68; } h(){t …

1337 or Leet in the UNIX time. -01:44:57– [email protected] [~]$ date +%s 1337096699 The missing days in 1752. I have mentioned this before, but it is worth mentioning again. -01:45:31– [email protected] [~]$ cal 9 1752 September 1752 Su Mo Tu We Th Fr Sa 1 2 14 15 16 17 18 19 20 21 22 …