// filename:c2011-7-29-2-2-ex.c // original examples and/or notes: // (c) ISO/IEC JTC1 SC22 WG14 N1570, April 12, 2011 // C2011 7.29.2.2 The fwscanf function // compile and output mechanism: // (c) Ogawa Kiyoshi, kaizen@gifu-u.ac.jp, December.29, 2013 // compile errors and/or warnings: // 1 (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. // 2 gcc-4.9 (GCC) 4.9.0 20131229 (experimental) // Copyright (C) 2013 Free Software Foundation, Inc. #include #include int main(void) { // Example 1 /* ... */ int n, i; float x; wchar_t name[50]; n = fwscanf(stdin, L"%d%f%ls", &i, &x, name); printf("%d %f %ls\n", i, x, name); // Example 2 /* ... */ // int i; float x; double y; fwscanf(stdin, L"%2d%f%*d %lf", &i, &x, &y); printf("%2d %f %lf\n", i, x, y); return printf("7.29.2.2 The fwscanf function \n"); } // execute command // ./a.out < c2011-7-29-2-2-ex.data // output may be // 25 5.432000 thompson // 56 789.000000 56.000000 // 7.29.2.2 The fwscanf function