How to concatenate string and int in C?

前端 未结 3 350
我在风中等你
我在风中等你 2020-12-07 17:27

I need to form a string, inside each iteration of the loop, which contains the loop index i:

for(i=0;i<100;i++) {
  // Shown in java-like cod         


        
3条回答
  •  攒了一身酷
    2020-12-07 17:51

    Look at snprintf or, if GNU extensions are OK, asprintf (which will allocate memory for you).

提交回复
热议问题