Code:
#include <stdio.h>
#include "string.h"
#define HTTP_URI_FMT "http://%s:%lu/%s"
#define IPCOMP(addr, n) ((addr >> (24 - 8 * n)) & 0xFF)
#define IP_ADDR_LEN 20
int main()
{
unsigned long i= 19216811;
static char UI8Ip[IP_ADDR_LEN];
unsigned long port = 80;
char folder[] = "anoop/anoop";
char buff[255];
snprintf((char *)UI8Ip, IP_ADDR_LEN, "%ld.%ld.%ld.%ld", IPCOMP(i, 3), IPCOMP(i, 2), IPCOMP(i, 1), IPCOMP(i, 0));
//sprintf(buff,"http://%lu:%lu/%s",i,port,buff);
snprintf(buff, 255, HTTP_URI_FMT, i, port, folder);
printf("Val of:%s",buff);
return 0;
}
I am struck with the segment fault
Regards,
Anoop