C++ Logo

std-proposals

Advanced search

[std-proposals] New printf/scanf modifiers

From: Lee Shallis <gb2985_at_[hidden]>
Date: Tue, 31 Jan 2023 18:40:47 +0000
since hh, h, etc are unused I decided to use them in my own
implementation (separate name to standard printf) and just now thought
to suggest them.

hh = char8_t (In my equivalent typedef I chose to default to wchar_t
when char is too small in a non standards compliant implementation)
h = char16_t
ll = char32_t (since l is reserved for wchar_t and the lack thereof for char)
t = tchar_t (TCHAR on windows and char on linux)
j = char32_t (since that's currently the biggest there is, we never
know if we'll ever need bigger, for example space alien character sets
- assuming they exist)

I also used v as a modifier for intptr_t/uintptr_t, took it from void*

Also I think .* should be used to indicate the max characters to scan
for any string, for example

#define LENG 7
char name[LENG+1] = "";
scanf("%.*s",LENG,name);

With the input of "Hello world!" would give "Hello w"

Received on 2023-01-31 18:41:29