Skip to main content

Posts

Showing posts with the label Programs

Sample C Program To Display Function Without Using The Main Function.

# include <stdio.h> #define decode(s,t,u,m,p,e,d) m##s##u##t #define begin decode(a,n,i,m,a,t,e) int begin() {     printf(" helloworld "); } OUTPUT: helloworld Sample C Program To Get IP Address. # include <stdio.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <netinet/in.h> #include <net/if.h> #include <unistd.h> #include int main() {     int n;     struct ifreq ifr;     char array[] = "eth0";     n = socket(AF_INET, SOCK_DGRAM, 0);     //Type of address to retrieve - IPv4 IP address     ifr.ifr_addr.sa_family = AF_INET;      //Copy the interface name in the ifreq structure     strncpy(ifr.ifr_name , array , IFNAMSIZ - 1);     ioctl(n, SIOCGIFADDR, &ifr);     close(n);     //d...