C program in Linux to find the current working directory (PWD)

getcwd, getwd, get_current_dir_name functions return a null-terminated string containing an absolute pathname that is the current working directory of the calling process. The pathname is returned as the function result and via the argument buf, if present.

C program to convert integer number to string

Following program converts integer number 42 to string “42” using sprintf. sprintf() writes to the character string. We can compile this program is using gcc as, We can compile run program on command line as,

How to write Comments in C Program ?

In C program, comments doesn’t have any use other than for better understanding of the developers of the source code in case you are writing big program and wants to remember what is the functionalities of the code blocks (functions/lines) in program. Single Line Comment — Any text on a single line after // is … Read more

Sending ARP request and receiving ARP Reply using C code

This post is in continuation of our previous post “Understanding ARP (Address Resolution Protocol) basics“ To visualise what ARP reply we are getting from arping command, we need to write an ARP reply receiver code as below, compile this code as, So, as we can see “arping” sent above ARP reply to broadcast destination mac … Read more

C program to know storage size of int, char and float

To get the exact size of a type or a variable on a particular platform, you can use the sizeof operator. The expressions sizeof(type) yields the storage size of the object or type in bytes. Following is an example to get the size of int type on any machine.

Subscribe for New Post Updates

Join 211 other subscribers