Search code examples
cwindowsdos

Running the Hello World C code from command prompt?


I have written a very simple C program to print "Hello World" in my Notepad text editor and saved it as test1.exe. I opened my cmd and ran the file test.exe and the received error is as follows:

The NTVDM CPU has encountered an Illegeal instruction. CS:0607 IP:0103 OP:63 6c 75 64 65 Choose 'Close' to terminate the application.


Solution

  • A few things to help you learn C in an easier manner:

    • First, you say you wrote it in Notepad. Bad choice for learning C. Notepad does not support Syntax highlighting.
    • Second, C needs to be compiled, on windows you have a few choice for compiler, the first would be MinGW which is Free.
    • Third, and IDE that is MinGW aware and C syntax aware is also needed. Geany is simple enough but is very smart and full of sweets.

    Finally, see the tutorial here, how to get them all working: geany+mingw on windows.

    One more thing, totally unrelated to C, or maybe it does. I bluntly assume that C is your first programming experience, or that you are still doing first steps in programming.
    C as a first language is VERY BAD. It is not forgiving, and most compilers pass things, but the code will crash, not letting you know what you did wrong.
    Consider learing other languages first, a few good choices would be:

    1. Python
    2. Lua
    3. Ruby