Category Archives: C

Learning by Doing: Programming Razz Simulator

Posted in kerneltrap.org on February 5, 2010 – 9:54am As a final assignment in my Languages for Scientific Computing class, I develop a Razz Simulator. Basically Razz is the inverse of Poker in which you try to come up with … Continue reading

Posted in C, Learning Experience, Programming Languages, Software Engineering | Tagged | 1 Comment

How to Get the Length of a UDP Datagram/Packet

Posted in kerneltrap.org on September 3, 2009 – 12:33pm While developing the logger for GNU/Linux Anywhere USB Controller, I needed to know the length of the UDP packet to be read so that I could do `malloc()’ with the appropriate … Continue reading

Posted in C, Programming Languages | Tagged | Leave a comment

Getting the File Name from a File Descriptor (fd) or a File Pointer (FILE *)

Posted in kerneltrap.org on September 3, 2009 – 11:51am While developing the logger for GNU/Linux Anywhere USB Controller, I created the following function that will store a `FILE *’ into a global table for a later retrieval: static int save_open_file … Continue reading

Posted in C, Programming Languages | Tagged | Leave a comment

Crafting Function: With or Without Buffer Length Parameter?

Posted in kerneltrap.org on August 4, 2009 – 2:07pm Developing a C API that deals with writing to external provided buffers, I was wondering whether or not I should include parameter buffer length when the length of the data to … Continue reading

Posted in C, Programming Languages | Tagged | 2 Comments

Should a header file includes another header file?

Posted in kerneltrap.org on July 10, 2009 – 5:12pm Now that I’d got another chance to develop a C application, whenever I crafted a header file, I always wondered whether the header file needed to include another header file such … Continue reading

Posted in C, Programming Languages | Tagged , , | 4 Comments

How to differentiate between EOF and a character whose ASCII code is 255

Posted in kerneltrap.org on June 1, 2008 – 10:05pm A call to fgetc() or getchar() will return EOF if the end-of-file has been reached. As far as I know, GNU C Library defines EOF to be (-1). Those who are … Continue reading

Posted in C, GNU C Library, Programming Languages | Tagged , , | 2 Comments

Printing size_t or ssize_t variable

Posted in kerneltrap.org on May 18, 2008 – 10:28pm Looking at the man page of printf (man 3 printf), in the length modifier section, it is written: z       A following integer conversion corresponds to a size_t or ssize_t argument. (Linux libc5 … Continue reading

Posted in C, GNU C Library, Programming Languages | Tagged , | Leave a comment