0

I have found two ways to define # in my code and would like to know the best practices way.
Here is the code:
int pound = 35 ;
char p = pound;
int space = 32 ;
char s = space;
char x = '#';

When I print them, they all print fine as in
# #
But is it overkill to define the ascii number as an int then convert it to a char? or does the extra code allow it to relate better?

0

NO. The second one is both direct and better. Use char x = '#'.

Rather i'd recommend to use straight "#" in printf without declaring any other unnecessary variables just like printf("# ");

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .