41 lines
1.1 KiB
C
Raw Normal View History

#include <stdio.h>
#include <string.h>
#include <wchar.h>
#include <locale.h>
/* Unicode in comments: Привет, 世界, 🌍 */
int main(void) {
setlocale(LC_ALL, "");
/* Unicode string literals */
wchar_t *greeting = L"こんにちは";
wprintf(L"%ls\n", greeting);
/* Null byte embedded */
char buf[] = "Hello\x00World";
printf("Length: %zu\n", strlen(buf)); /* stops at null byte */
/* Deeply nested structs */
struct a { int x; };
struct b { struct a a; };
struct c { struct b b; };
struct d { struct c c; };
struct e { struct d d; };
struct f { struct e e; };
struct f val = {{{{{{42}}}}}};
printf("%d\n", val.e.d.c.b.a.x);
/* Very long function name */
void this_is_an_extremely_long_function_name_that_goes_on_and_on_and_on(void) {
printf("deep\n");
}
this_is_an_extremely_long_function_name_that_goes_on_and_on_and_on();
/* Encoding: BOM-like byte sequences */
unsigned char raw[] = {0xEF, 0xBB, 0xBF, 'A', 'B', 'C', 0};
printf("%s\n", raw);
return 0;
}