How to concatenate two ints into a string in C

1 Answer

0 votes
#include <stdio.h>

int main() {
    int n1 = 13;
    int n2 = 898;
    char buf[32] = "";

    snprintf(buf, 32, "%d %d", n1, n2);
    printf("%s\n", buf);

    return 0;
}




/*
run

13 898

*/

 



answered May 3, 2021 by avibootz

Related questions

1 answer 155 views
3 answers 277 views
1 answer 137 views
1 answer 225 views
1 answer 155 views
3 answers 220 views
220 views asked Jun 13, 2017 by avibootz
...