大家好我试图分配string到char *指针.以下是我的工作方式,但我收到此警告: assignment makes integer from pointer without a cast.
在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);
Run Code Online (Sandbox Code Playgroud) 我们有一段C代码如下.任何解决方案都会导致所有声明并初始化
void fillProcess(void *unused, Uint8 *stream, int len)
{
Uint8 *waveptr;
int waveleft=0;
waveptr = wave.sound + wave.soundpos;
waveleft = wave.soundlen - wave.soundpos;
while ( waveleft <= len ) {
/* Process samples */
Uint8 process_buf[waveleft];
SDL_memcpy(process_buf, waveptr, waveleft);
/* do processing here, e.g. */
/* processing the audio samples in process_buf[*] */
// play the processed audio samples
SDL_memcpy(stream, process_buf, waveleft);
stream += waveleft;
len -= waveleft;
// ready to repeat play the audio
waveptr = wave.sound;
waveleft = …Run Code Online (Sandbox Code Playgroud)