One of the short and sweet function which i have written in C language is dotted_decimal_to_string(). This function takes individual fields as inputs returns dotted decimal string. This is used in taking dotted decimal values of network parameters like IP address, IP netmask, IP gateway address, DNS server IP address etc, from the webpage, where these network parameters are individual inputs from a form.
Check out the function.
This function stuck to my mind while i was going to bed yesterday. That means, my back-office was working for me, and giving me such a cute solution.
Otherwise I dont keep solutions short, they are always complex for little task also. :-)
Check out the function.
The return string is a dotted decimal value for a network parameter and is used to store in configuration file or to use for setting and configuring the Network parameters.
char *dotted_decimal_to_string(char *pad1, char *pad2, char *pad3, char *pad4)
{
char temp[40],*ret_string;
sprintf(temp,"%s.%s.%s.%s",pad1,pad2,pad3,pad4);
ret_string = (char*)malloc(strlen(temp) + 1);
strcpy(ret_string,temp);
return ret_string;
}
This function stuck to my mind while i was going to bed yesterday. That means, my back-office was working for me, and giving me such a cute solution.
Otherwise I dont keep solutions short, they are always complex for little task also. :-)
Comments
Just join the largest community of RTU students and x-students plus a lot of faculties.
Join www.heyrtu.com
Come on join the discussion !