// filename:c2011-K-3-9-2-1-2-ex.c // original examples and/or notes: // (c) ISO/IEC JTC1 SC22 WG14 N1570, April 12, 2011 // C2011 K.3.9.2.1.2 The wcsncpy_s function // compile and output mechanism: // (c) Ogawa Kiyoshi, kaizen@gifu-u.ac.jp, December.29, 2013 // compile errors and/or wornings: // (c) Apple LLVM version 4.2 (clang-425.0.27) (based on LLVM 3.2svn) // Target: x86_64-apple-darwin11.4.2 //Thread model: posix // (c) LLVM 2003-2009 University of Illinois at Urbana-Champaign. // Example 1 #define __STDC_WANT_LIB_EXT1__ 1 #include #include #include int main(void) { /* ... */ wchar_t src1[100] = L"hello"; wchar_t src2[7] = {L'g', L'o', L'o', L'd', L'b', L'y', L'e'}; wchar_t dst1[6], dst2[5], dst3[5]; int r1, r2, r3; r1 = wcsncpy_s(dst1, 6, src1, 100); r2 = wcsncpy_s(dst2, 5, src2, 7); r3 = wcsncpy_s(dst3, 5, src2, 4); return printf("K.3.9.2.1.2 The wcsncpy_s function %d %d %d \n",r1,r2,r3 ); } // output may be