How to print the first 3 characters of a string in C

1 Answer

0 votes
#include <stdio.h>

int main() {
    char s[] = "c programming";
    
    printf("%.*s", 3, s);

    return 0;
}



 


/*
run:

c p

*/

 



answered Mar 3, 2021 by avibootz

Related questions

1 answer 196 views
1 answer 196 views
1 answer 209 views
1 answer 265 views
1 answer 203 views
1 answer 237 views
1 answer 215 views
...