Tag Archives: c

Get time difference in microtime in C

By | March 9, 2012

The function gettimeofday can be used to retrieve the total number of seconds and balance microseconds elapsed since EPOCH. Structure timeval looks like this : struct timeval { time_t tv_sec; /* seconds */ suseconds_t tv_usec; /* microseconds */ }; On Linux it can be done like this : /** * Get time difference in microseconds… Read More »

How to Get IP Whois Data in C with Sockets on Linux – Code Example

By | August 7, 2020

Theory The whois information of an ip address provides various details like its network, range, isp etc. This information is maintained by various regional registry servers. Read the wikipedia article on regional internet registries for more information. There are a total of 5 regional registries spanning various geographical regions of the world. For example if… Read More »

str_replace for C

By | December 22, 2011

Php has a useful function called str_replace which can search and replace a certain string in another big string. However there is no such function in C. So I wrote up one for myself. Here is the code. /* * Search and replace a string with another string , in a string * */ char… Read More »