How to enable printf() function from printing Boolean types in C with defining new identifier in printf("%ex",test())? -


this question has answer here:

i trying add new identifiers printf() function enable printing "true" , "false" .. eg:printf("%boolean",test()); possible in c ?

#include<stdio.h> typedef int boolean; #define true 1 #define false 0  boolean test(int x){ return x%2==0?1:0;                 }  int main(){ printf("%s",test(5)); system("pause"); return 0; } 

change

printf("%s",test(5)); 

to

printf("%s",(test(5))?"true":"false"); 

which tells %s print "true" if test(5) returns non-zero integer , "false" if test(5) returns 0.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -