Hi all I trying to assign string into a char * pointer. Below is how I am doing but I am getting this warning: assignment makes integer from pointer without a cast.
What is the correct why to deal with strings in C ?
char* protoName = "";
if(h->extended_hdr.parsed_pkt.l3_proto==0)
*protoName = "HOPOPT";
else if(h->extended_hdr.parsed_pkt.l3_proto==1)
*protoName = "ICMP";
else if(h->extended_hdr.parsed_pkt.l3_proto==2)
*protoName = "IGMP";
else if(h->extended_hdr.parsed_pkt.l3_proto==3)
*protoName = "IGMP";
else if(h->extended_hdr.parsed_pkt.l3_proto==4)
*protoName = "IGMP";
char all[500];
sprintf(all,"IPv4','%s'",* protoName);
char *protoNamedefines a pointer to a character, calledprotoName. There's no such thing as a "list of char". The pointer can point to a singlechar, it can point to an array ofchar, it can point to a string and for all those combinations, it can be pointing to memory on stack or the heap. It can also point to junk, but that's an answer for another question.