Miscellaneous programming tricks with C.

This is a very simple Hello World program in C. int main() { write(1, "Hello World\n", 14); }int main() { write(1, "Hello World\n", 14); } Counting how long a text string is. #include <stdio.h> #include <string.h> #define MSG "Hello Doctor, let’s get back to the TARDIS!" int main() { int g; g = strlen(MSG); if … Read more

Cyberpunk 2077 is a very bad game. Developers cannot program anymore.

The anticipated new game Cyberpunk 2077 has launched and it is not very good at all. There are severe performance issues and it is not very polished at all. That is what happens when developers release a trash game at the set date and then depend upon patches after the fact to fix various issues. … Read more

Very useful C code samples. These might be very useful to someone.

Some very useful code samples for any C programmer. These might give you some new ideas. Print the time and date with C. #include <time.h> // For time function (random seed). #include <stdio.h> // For extra functions. printf(). #include <stdlib.h> // For getenv();   #define format "The time and date is: %A %d %B %Y. … Read more

Some useful FizzBuzz examples for budding programmers.

Here are some useful FizzBuzz programming examples in various programming languages. These might prove useful as code samples that could be expanded into a larger project or just for interests sake. Very useful if you wish to learn how to program, taking these programs apart and modifying them would be a lot of fun. In … Read more

Some very good Linux resources for learning programming and BASH scripting.

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 you … Read more

Miscellaneous Perl programming information. How to use for loops and printing HTML properly.

Opening a folder and listing the contents, and not listing certain files. This is the Perl code I was using on my very old Tripod.com website. opendir(DNAME, "$folder") || die "I cannot open the requested directory $folder \n $!"; @dirfiles2 = readdir (DNAME); @dirfiles2 = sort(@dirfiles2); foreach $x2 (@dirfiles2) { if ($x2 eq ".") { … Read more

Cool C programming trick, run /bin/sh with the C execve() function.

This programming trick is pretty cool, you can run the /bin/sh shell with a C program. The execve() function is useful for running a command within a C program and passing arguments to it, but I have replaced the arguments with NULL instead, that is what you put when you do not need arguments. #include … Read more

Cool C programs and some very useful code snippets to make programming even more fun.

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 … Read more

Running a command within another program. How to do this with C.

This code snippet will run the date command. The execl() function is very useful for executing a command within your C program.You replace the NULL identifiers with any extra arguments to pass to the program. I prefer this over the system() function. #include <unistd.h>   int main(void) {   execl("/bin/date", "%c", NULL, NULL, NULL); return … Read more

Sample C programming code. How to get input from the console.

This is a sample C program showing how to define a function as well as accepting input from the command-line. Hopefully this is useful for someone who is writing a console application for Linux or UNIX. #include <stdio.h> #include <string.h>   int main(int argc, char **argv) {   char *name; name = argv[1];   if … Read more