How to remove first character from C-string?

后端 未结 7 1217
小鲜肉
小鲜肉 2021-02-04 01:52

Can anyone please help me? I need to remove the first character from a char * in C.

For example, char * contents contains a \'\\n\'

7条回答
  •  深忆病人
    2021-02-04 02:10

    #include 
    #include 
    
    int main ()
     {
    char src[50] = "123456789123434567678";
    
    char dest[16]={0};
     memcpy(dest, src+1,sizeof(src));
     printf("%s\n",dest);
     return(0);
    }
    
    src+1 -> indicate how many char you want to remove
    

提交回复
热议问题