c++ - printf("%cx", FILE2CHAR(F(fr))) to cout -
how can express printf("%cx", file2char(f(fr)))
"cout"? (note: file2char(f(fr)) returns int`)
i have tried cout<<hex<<file2char(f(fr));
in cases, still returns me wrong hex.
my mistake. file2char(f(fr)) not homecoming int. f(fr) returns int
file2char macro:
#define file2char(f) ('a'+(f)) /* file text */
sorry confusion please help~
thankswhat trying print? %cx print character followed x. why utilize hex manipulator anyway? – parkydr because thought x refers hex, right? kind of confused syntax here.
still bit confused i'll cover both situations.
to print character, printf should be
printf("%c", file2char(f(fr)));
the stream equivalent is
cout << static_cast<char>(file2char(f(fr)));
the cast required because file2char homecoming integer cout display integer value.
to print hex value, printf should be
printf("%x", file2char(f(fr)));
the stream equivalent is
cout << hex << file2char(f(fr));
note: subsequent numbers displayed in hex until utilize dec manipulator.
c++ printf cout
No comments:
Post a Comment