How to use strncpy in C

1 Answer

0 votes
#include <stdio.h>
#include <string.h>

int main () {
   char src[32] = "c c++ java";
   char dest[16];
  
   strncpy(dest, src, 7);

   printf("%s", dest);
   
   return 0;
}




/*
run:

c c++ j

*/

 



answered Apr 5, 2022 by avibootz

Related questions

...