简体   繁体   中英

My C "Hello, world!" program isn't compiling

I wanted to learn C, so I decided to start a C project and try out the canonical "Hello, world." program in Visual Studio.

So I put this code in

#import <stdio.h>

main()
{
    printf("Hello, world!");
}

and got three errors:

IntelliSense: cannot open source file "C:/.../stdio.tlh"
IntelliSense: identifier "printf" is undefined
IntelliSense: PCH warning: cannot find a suitable header stop location. An intellisense PCH file was not generated.

Apparently I'm setting up my project wrong or I don't have the header files I need or something like that.

I'm sure this seems like a really basic problem, but I haven't really used C before so I'm stuck and don't know what to do. What am I doing wrong and how do I fix it?

#import should be #include .

It's not #import , it's #include .

You should use #include instead of #import

Couple of points that others have not pointed out:

  1. main() should return int
  2. Your string literal argument to printf should have a new line.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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