简体   繁体   English

如何在不使用C语言的头文件的情况下编写Hello World

[英]How to write hello world without using header file in c

How to write hello world without using header files in C? 如何在不使用C语言的头文件的情况下编写Hello World?

#include<conio.h>
#include<stdio.h>

void main(){

printf("Hello World");
getch();

}

This is simple C program with header file... 这是带有头文件的简单C程序...

  • conio.h - for console conio.h用于控制台
  • stdio.h - is used for printf and scanf stdio.h用于printfscanf

You need header files primarily because of the prototype declaration of library functions plus any necessary types and additional macros needed to facilitate their use. 您之所以需要头文件,主要是因为库函数的原型声明以及任何方便使用它们所需的必要类型和附加宏。 They are provided in form of header files for ease of re-use. 它们以头文件的形式提供,以便于重复使用。

In your case, you can write the prototypes on your own and you should be okay Something like 在您的情况下,您可以自己编写原型,并且应该可以。

/*  Prototypes on your own */
int getchar(void);
int printf(const char *format, ...);
int puts(const char *s);

int main(void) {  //this is the prescribed signature for hosted environment
    //printf("Hello World\n");    //not good to use printf if don;t need conversion
    puts("Hello World");
    //getchar();
    return 0;
}

should do just fine. 应该做得很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM