Archive

Archive for December, 2014

How To – Get Current Time in C

December 27th, 2014 No comments

C Code to fetch current system timestamp

#include
#include

int main ()
{
time_t rawtime;
struct tm * timeinfo;

time ( &rawtime );
timeinfo = localtime ( &rawtime );
printf ( “Current local time and date: %s”, asctime (timeinfo) );

return 0;
}

Read more…

Categories: Programming Tags:

How To – Clear content of an entire String or Array

December 20th, 2014 No comments

If you want to zero the entire contents of the string, you can do it this way:

memset(buffer,0,strlen(buffer));

but this will only work for zeroing up to the first NULL character.

If the string is a static array, you can use:

memset(buffer,0,sizeof(buffer));

Categories: ActionScript Tags:

How To – Creating a Variable Query in PostGreSQL using libpq in C

December 18th, 2014 No comments

If you don’t have libpq, you can install it using the following command in Debian

apt-get install libpq-dev

The following code shows how to create an INSERT query using strings and pass it on to the PQexec() function.

#include

#include

//#include

//

#include

int     main() {

PGconn          *conn;

PGresult        *res;

int             rec_count;

int             row;

int             id = 1;

char           dtype = ‘W’;

char           maci[19] = {0};

char            buf[256] = {0};

snprintf(maci,18,”E8:4E:84:A8:68:9C”);

puts(maci);

Read more…

Categories: Programming Tags: