卓越飞翔博客卓越飞翔博客

卓越飞翔 - 您值得收藏的技术分享站
技术文章19447本站已运行343

写一个C程序,打印“ Tutorials Point ”,不使用分号

写一个C程序,打印“ Tutorials Point ”,不使用分号

在不使用分号的情况下打印任何字符串,我们需要了解标准输出的工作原理以及为什么使用分号。

分号是一种行结束语句,用于告诉程序该行在此结束。这里使用的标准打印语句printf是标准io库的一种方法。让我们深入了解printf()方法。

'
int printf(const char *format , ...)

This method returns an integer and has a set of arguments format and … . The format is a string that is printed in the output screen. And the … is the additional number of arguments that are given to the function based on the string.

The funnctions return the total number of character that is to be printed on the screen.

Using this we can find ways to bypass the use of end of line statement while printing the statement. We can use some statements that do not require the end of LINE statement to execute like the for loop. We can use this to print are set a statement without using the semicolon.

There are several methods by which we can print statement without using the semicolon;

Using the if condition

'
#include<stdio.h>
int main() {
   if (printf("Tutorials point") )
   { }
}

Using the switch statement

'
#include<stdio.h>
int main() {
   switch (printf("Tutorials point") )
   { }
}

Using the while loop

'
#include<stdio.h>
int main() {
   while (printf("Tutorials point") )
   { }
}

使用宏

'
#include<stdio.h>
#define Out printf("Tutorials point")
int main() {
   switch (out)
   { }
}
卓越飞翔博客
上一篇: 了解PHP底层开发原理:编码规范和最佳实践指南
下一篇: 返回列表
留言与评论(共有 0 条评论)
   
验证码:
隐藏边栏