小编use*_*681的帖子

C将字符串插入char指针

大家好我试图分配stringchar *指针.以下是我的工作方式,但我收到此警告: 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 string

4
推荐指数
1
解决办法
2346
查看次数

期望的持续表达

我们有一段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)

c arrays

1
推荐指数
1
解决办法
291
查看次数

标签 统计

c ×2

arrays ×1

string ×1