| 41 | } |
| 42 | |
| 43 | int main () |
| 44 | { |
| 45 | FILE *f = fopen("test.dat", "wb"); |
| 46 | int num = fwprintf(f, L"hello %d", 5); |
| 47 | wprintf(L"fwprintf told us %d\n", num); |
| 48 | fclose(f); |
| 49 | f = fopen("test.dat", "rb"); |
| 50 | fseek(f, 0, SEEK_END); |
| 51 | int size = ftell(f); |
| 52 | fclose(f); |
| 53 | wprintf(L"file size is %d\n", size); |
| 54 | |
| 55 | wchar_t str[] = L"test string has %d wide characters.\n"; |
| 56 | wprintf(L"str starts with 0x%x\n", *(int*)str); |
| 57 | wprintf(L"str continues with 0x%x\n", *(((int*)str) + 1)); |
| 58 | wprintf(L"str continues with 0x%x\n", *(((int*)str) + 2)); |
| 59 | PrintWide ( str, wcslen(str) ); |
| 60 | PrintWide ( str, wcslen(str) ); |
| 61 | PrintWide ( str, wcslen(str) ); |
| 62 | |
| 63 | |
| 64 | wchar_t long_str[] = L"test string has %d wide characters.\n" |
| 65 | "Internally the variadic print functions use a 256 char buffer, so this is a string that's longer than 256 chars, " |
| 66 | "so in case this breaks we have a test case. As discovered in #9305 vswprintf had been broken for some time, " |
| 67 | "but was never picked up as the test strings were all shorter then 256 chars. So hopefully this long rambly string " |
| 68 | "will help guard against that bug being re-introduced.\n"; |
| 69 | PrintBigWide ( long_str, wcslen(long_str) ); |
| 70 | |
| 71 | wprintf (L"Characters: %lc %lc \n", L'a', 65); |
| 72 | wprintf (L"Decimals: %d %ld\n", 1977, 650000L); |
| 73 | wprintf (L"Preceding with blanks: %10d \n", 1977); |
| 74 | wprintf (L"Preceding with zeros: %010d \n", 1977); |
| 75 | wprintf (L"Some different radixes: %d %x %o %#x %#o \n", 100, 100, 100, 100, 100); |
| 76 | wprintf (L"floats: %4.2f %+.0e %E \n", 3.1416, 3.1416, 3.1416); |
| 77 | wprintf (L"Width trick: %*d \n", 5, 10); |
| 78 | wprintf (L"%ls \n", L"A wide string"); |
| 79 | |
| 80 | wchar_t buffer [100]; |
| 81 | memset(buffer, 0, sizeof(buffer)); |
| 82 | int cx; |
| 83 | cx = swprintf(buffer, 100, L"The half of %d is %d", 80, 80/2); |
| 84 | wprintf(L"swprintf told us %d\n", cx); |
| 85 | for (int i = 0; i < 10; i++) wprintf(L"pre %d\n", ((int*)buffer)[i]); |
| 86 | swprintf (buffer+cx, 100-cx-1, L", and the half of that is %d.\n", 80/2/2); |
| 87 | for (int i = 0; i < 10; i++) wprintf(L"post %d\n", ((int*)buffer)[i]); |
| 88 | wprintf(buffer); |
| 89 | |
| 90 | return 0; |
| 91 | } |
| 92 |
nothing calls this directly
no test coverage detected