#include <stdio.h>
#define STRNCPY(DST, ORG, N) { \
char *s1 = (DST); \
const char *s2 = (ORG); \
size_t n = (N); \
int i; \
for (i = 0; i < n && s2[i] != 0; i++) \
{ \
s1[i] = s2[i]; \
} \
s1[i] = 0; }
int main (void)
{
char stringa[100];
STRNCPY (stringa, "Buon giorno a tutti!", 50) // [1]
// [1] Si osservi che manca il
// punto e virgola finale!
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgojZGVmaW5lIFNUUk5DUFkoRFNULCBPUkcsIE4pIHsgXAogICAgY2hhciAqczEgPSAoRFNUKTsgXAogICAgY29uc3QgY2hhciAqczIgPSAoT1JHKTsgXAogICAgc2l6ZV90IG4gPSAoTik7IFwKICAgIGludCBpOyBcCiAgICBmb3IgKGkgPSAwOyBpIDwgbiAmJiBzMltpXSAhPSAwOyBpKyspIFwKICAgICAgeyBcCiAgICAgICAgczFbaV0gPSBzMltpXTsgXAogICAgICB9IFwKICAgIHMxW2ldID0gMDsgfQoKaW50IG1haW4gKHZvaWQpCnsKICBjaGFyIHN0cmluZ2FbMTAwXTsKICBTVFJOQ1BZIChzdHJpbmdhLCAiQnVvbiBnaW9ybm8gYSB0dXR0aSEiLCA1MCkgICAvLyBbMV0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIFsxXSBTaSBvc3NlcnZpIGNoZSBtYW5jYSBpbAogICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gICAgIHB1bnRvIGUgdmlyZ29sYSBmaW5hbGUhCiAgcHJpbnRmICgiJXNcbiIsIHN0cmluZ2EpOwogIHJldHVybiAwOwp9Cg==