strncpy() fails on second call for same source

后端 未结 1 1477
说谎
说谎 2021-01-28 16:31

I\'m new with c and want to separate string in two parts. Here is my code:

#include 
#include 
#include 

void tes         


        
相关标签:
1条回答
  • 2021-01-28 16:49

    The array-subscript-operator [] has higher precedence then the dereferencing operator *.

    So you want to change

    *a[3] = ...
    

    to be

    (*a)[3] = ...
    

    Same for b.


    Having set the compiler's warning level high enough, it should have warned you about this. Or at least told you that their is something fishy with

    *a[3] = '\0';
    
    0 讨论(0)
提交回复
热议问题