Assigning strings to arrays of characters

后端 未结 9 1380
小鲜肉
小鲜肉 2020-11-22 15:03

I am a little surprised by the following.

Example 1:

char s[100] = \"abcd\"; // declare and initialize - WORKS

Example 2:



        
9条回答
  •  醉话见心
    2020-11-22 15:51

    You can use this:

    yylval.sval=strdup("VHDL + Volcal trance...");
    

    Where yylval is char*. strdup from does the job.

提交回复
热议问题