Does anyone know why the type of argument putchar(), fputc()and putc()did not char, but the type of argument putwchar(), fputwc()and putwc()equal wchar_t? See also this and this .
putchar()
fputc()
putc()
char
putwchar()
fputwc()
putwc()
wchar_t
The answer is “legacy” (or “history”). Prior to the C90 standard, there were no prototypes of functions, and all arguments for all functions were subject to the default distribution rules, therefore a was charautomatically passed as int( shortwas upgraded to int), and floatto double, and similarly for unsigned types). The standard could not afford to break existing code, so it retained this type for these functions. This has almost no effect on practice. The value you pass will be considered as a character type, even if you pass a value that is out of range. The specification fputc(int c, FILE *stream)says:
int
short
float
double
fputc(int c, FILE *stream)
The function fputcwrites the character specified c(converted to unsigned char) to the output stream pointed to stream...
fputc
c
unsigned char
stream
§6.5.2.2¶6 , , , , , float, . ....¶7... . .
¶6 , , , , , float, . ....
¶7... . .
6.3.1.
¶2 :21 > unsigned int:( int unsigned int), int unsigned int._Bool, int, signed int unsigned int.int ( , a -), int; unsigned int. . 58) .¶3 , . , "plain" char , .58) : , , +, - ~, , .
¶2 :21 > unsigned int:
unsigned int
_Bool
signed int
int ( , a -), int; unsigned int. . 58) .
¶3 , . , "plain" char , .
58) : , , +, - ~, , .
+
-
~
¶1 10 .
, . . , , char ( int), EOF, char ,
EOF
void f(char c) { ... ... char x = 't'; f((unsigned char)x); ... warning: conversion to ‘char’ from ‘unsigned char’ may change the sign of the result
( unsigned char , , char undefined.) , - int.
Source: https://habr.com/ru/post/1661443/More articles:opts_knit $ set (root.dir = path) does not work after updating RStudio 1.0.44 - rHow to change wchar.h so that wchar_t is the same type as wint_t? - glibcОбнаружение шаров на бильярдном столе - image-processingОшибка паролей модуля webpack Неожиданный символ '@' - webpackAfter fast migration 3, compilation became slow - compilationMismatch in the definitions of fputwc (), putwc () and putwchar () in glibc - cDocker postgres image extension to create an additional database - dockerSpark cassandra: combine the table with the query condition based on the attribute from the primary RDD ("where tableA.myValue> tableB.myOtherValue") - cassandraAngular 2: NgFor without an HTML tag? - angularUnicodeEncodeError: ascii codec cannot encode characters at positions 5-6: serial number not in range (128) - python-3.xAll Articles