-4
#include <stdio.h>
void main(void)
{
   printf("hello");
}    

enter image description here

I can’t seem to get the code to run. I tried using some extensions/terminal but the problem does not solve.

Barmar
  • 741,623
  • 53
  • 500
  • 612
  • 2
    Please edit your post to make the code compilable. Then add to the post (a) what the compiler emits when it runs, (b) what the compiled code emits when it runs, (c) what you want it to emit. – Jeff Holt Aug 10 '21 at 00:25
  • Read [ask] and post an [mcve]. – jwdonahue Aug 10 '21 at 00:45
  • You may want to read this: [Why not upload images of code/errors when asking a question?](https://meta.stackoverflow.com/q/285551/12149471) – Andreas Wenzel Aug 10 '21 at 00:54
  • Pasting a picture of your ide window is not normal behavior at SO. Instead, you should have copy+pasted all of the text in the OUTPUT pane into your post. Once you paste it in your post, you click the `{}` editor button to format it verbatim. – Jeff Holt Aug 10 '21 at 00:55
  • 1
    I don't use your ide but my guess is you're using either the wrong signature for `main` or you don't have VS configured correctly to compile and link. One of the only two proper signatures for main is `int main (int argc, char *argv[]);`. Yours isn't one of them. – Jeff Holt Aug 10 '21 at 00:56
  • 1
    Try `int main(void)` instead of `void main(void)`. – Andreas Wenzel Aug 10 '21 at 00:58
  • And if `int main(void)` doesn't work, try `int main(int argc, char **argv)`. – jason44107 Aug 10 '21 at 02:21
  • You may find [C/C++ for Visual Studio Code](https://code.visualstudio.com/docs/languages/cpp) helpful. – David C. Rankin Aug 10 '21 at 05:54
  • 1
    If you've just started learning, then immediately get rid of your source of learning and find a new one, before it teaches you more bad and incorrect things. In particular, avoid fishy online tutorials, old books and incompetent teachers. – Lundin Aug 10 '21 at 08:41

2 Answers2

0

hello C in VSCodeIf you use int as the type of main, it would be a good idea to include a return statement. The following works in VS Code

#include <stdio.h>

int main()
{
    printf("Hello");

    return 0;
}
HiEd
  • 160
  • 3
  • 1
    According to [§5.1.2.2.3 of the ISO C standard](http://port70.net/~nsz/c/c11/n1570.html#5.1.2.2.3), a `return` statement is not required for the function `main`. Reaching the end of the function without a `return` statement is equivalent to writing `return 0;`. However, I personally do consider it good coding style to write a `return` statement, even if it is not necessary. – Andreas Wenzel Aug 10 '21 at 09:59
0

You need int main (void), not void main(void).

See the Microsoft documentation.

user438383
  • 5,716
  • 8
  • 28
  • 43
bzImage
  • 21
  • 5
  • 1
    When answering a platform-neutral question, I don't think it is appropriate to post a link to platform-specific documentation (in this case for Microsoft Windows), as that documentation contains information that does not apply to other platforms. Therefore, it would be better to post a [corresponding link to platform-neutral documentation](https://en.cppreference.com/w/c/language/main_function), which only documents the ISO C standard and nothing platform-specific. – Andreas Wenzel Aug 10 '21 at 09:36