如何打印分号(;)在C/C++中不使用分号?

另一个有趣的问题是,如何在程序中不使用分号的情况下打印分号。以下是打印“;”的方法:

null
  1. 在中使用printf/putchar 声明如果 :

    // CPP program to print
    // ; without using ;
    // using if statement
    #include <stdio.h>
    int main()
    {
    // ASCII value of semicolon = 59
    if ( printf ( "%c" , 59))
    if ( putchar (59))
    {
    }
    return 0;
    }

    
    

    输出:

    ;
    ;
    

    我们还可以使用switch/while/for打印分号,如中所示 文章

  2. 使用 宏:

    // CPP program to print
    // ; without using ;
    // using macros
    #include <stdio.h>
    #define GEEK printf("%c",59)
    int main()
    {
    if (GEEK)
    {
    }
    }

    
    

    输出:

    ;
    

相关文章: 在C/C中打印不带分号的Hello World++

如果你喜欢Geeksforgek,并且想贡献自己的力量,你也可以使用 贡献极客。组织 或者把你的文章寄到contribute@geeksforgeeks.org.看到你的文章出现在Geeksforgeks主页上,并帮助其他极客。

如果您发现任何不正确的地方,或者您想分享有关上述主题的更多信息,请写下评论。

© 版权声明
THE END
喜欢就支持一下吧
点赞9 分享