本文介绍了关于main(int x)... main(void)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该程序的输出是什么

what is the output of this programme

#include <stdio.h>

int main(int x)
{
    printf("Hello, World!\n");
main(10);
    return 0;
}





并假设我们提到main(10)

而不提及其原型为main(int x)那么为什么结果仍然被多次打印?

并假设我使用主(无效)术语然后实际意味着什么......我们是主要的10次或者所以?



and suppose if we mention main(10)
without mentioning its prototype as main(int x) then why is the result still being printed multiple times?
and suppose if i use the main(void) term then what it actually means...are we calling main 10 times or so?

推荐答案

#include <stdio.h>

int main(int x)
{
    // create a loop to print the values
    for (int i = 0; i < x; i++)
       printf("Hello, World!\n");
    return 0;
}





调用main函数并立即传递值。您可以使用相同的逻辑,通过使用for循环调用main函数10次等等。



Call the main function and pass the value now. You can use the same logic, to call the main function 10 times by using a for loop and so on.



这篇关于关于main(int x)... main(void)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 21:36
查看更多