Quantcast
Viewing all articles
Browse latest Browse all 5107

C/C++ • Re: Two-dimensional array of character strings in C

Having looked at the printf escape sequences :-

The following escape sequences are defined in standard C. This table also shows the values they map to in ASCII. However, these escape sequences can be used on any system with a C compiler, and may map to different values if the system does not use a character encoding based on ASCII.

Escape sequenceHex value in ASCIICharacter represented
\a07Alert (Beep, Bell) (added in C89)[1]
\b08Backspace
\enote 11BEscape character
\f0CFormfeed Page Break
\n0ANewline (Line Feed); see notes below
\r0DCarriage Return
\t09Horizontal Tab
\v0BVertical Tab
\\5CBackslash
\'27Apostrophe or single quotation mark
\"22Double quotation mark
\?3FQuestion mark (used to avoid trigraphs)
\nnnnote 2anyThe byte whose numerical value is given by nnn interpreted as an octal number
\xhh…anyThe byte whose numerical value is given by hh… interpreted as a hexadecimal number
\uhhhhnote 3noneUnicode code point below 10000 hexadecimal (added in C99)[1]: 26 
\Uhhhhhhhhnote 4none

Was thinking I could use vprintf again to create a function call cprintf(..........);

So can you pass the formatting into printf and sprintf as a variable and how to deal with multi arguments to a function
You'll need to use the va_copy macro and use the variants of printf that are prefixed with a "v" (e.g. vsnprintf).

See https://en.cppreference.com/w/c/io/vfprintf#Example for an example.
So you could do something like cprintf("some text \cblack %s \cblue %d \z back to normal \n",string_data,int_data);

Statistics: Posted by Geralds — Sun Feb 11, 2024 8:56 pm



Viewing all articles
Browse latest Browse all 5107

Trending Articles