fork download
  1. #include <stdio.h>
  2.  
  3. #define STRNCPY(DST, ORG, N) { \
  4.   char *s1 = (DST); \
  5.   const char *s2 = (ORG); \
  6.   size_t n = (N); \
  7.   int i; \
  8.   for (i = 0; i < n && s2[i] != 0; i++) \
  9.   { \
  10.   s1[i] = s2[i]; \
  11.   } \
  12.   s1[i] = 0; }
  13.  
  14. int main (void)
  15. {
  16. char stringa[100];
  17. STRNCPY (stringa, "Buon giorno a tutti!", 50) // [1]
  18. // [1] Si osservi che manca il
  19. // punto e virgola finale!
  20. printf ("%s\n", stringa);
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0.01s 1720KB
stdin
Standard input is empty
stdout
Buon giorno a tutti!