c - Printing macro from an array -
c - Printing macro from an array -
#define ________ 0x0 #define _______x 0x1 #define ______x_ 0x2 #define ______xx 0x3 #define _____x__ 0x4
i have created macros store few sets of characters integer values in .h file shown above create .h file usable in other files.
if include .h file in other .c file containing char arrays such ch[] = {________,_______x}
there anyway me print actual sets of characters i.e "____" ch[0] , "_______x" ch[1]. when seek print prints char value corresponding integer values i.e 0 , 1. please allow me know command can utilize print same.
a character is, definition, single character. therefore, printing single character such 0x2 never print several characters such "_ _ _ _ _ _ x _". way you'd creating array of char * (strings in c char *) rather array of char. in,
char **mystrings = {"________", "_______x", "______x_", etc.}
then, can use
printf("%s", mystrings[______x_]);
which print
______x_
c arrays macros header-files
Comments
Post a Comment