-4

I started recently with programming and this is what I wrote:

#include <stdio.h>
int main() {
    int a,b,c;

    a=2;
    b=7;
    c=a+b;

    printf ("c vale %d\n;c");

    return 0;
}

Something simple I thought but then this error tends to appear:

C:/MinGW/i686-pc-mingw32/lib/libmingw32.a(lib32_libmingw32_a-crt0_c.o):crt0_c.c:(.text+0x3c): undefined reference to `WinMain@16'

can anyone explain me step by step what should I fix?

8
  • 2
    This happens when you attempt to compile the program as a windowed app instead of a console app. Nov 14, 2015 at 23:22
  • How are you compiling? Please post the full command line (it seems you are using MinGW, probably incorrectly). Nov 14, 2015 at 23:23
  • 7
    See if this question helps you. Note that you gave printf one too few arguments, which the compiler is capable of warning about.
    – chris
    Nov 14, 2015 at 23:23
  • C is not C++ is not C! Pick a language! Nov 14, 2015 at 23:24
  • 2
    @user3386109 pssh, typos. should be printf("c value %d\n", c); (clearly)
    – Insane
    Nov 14, 2015 at 23:51

1 Answer 1

0

Compile as console and change this line

   printf ("c vale %d\n;c");

to

    printf ("c vale %d\n", c);  // vale or value ???
2
  • 2
    Compile as console isn't that informative. If one has to ask this kind of question, one isn't likely to know how to change that information.
    – Tas
    Nov 14, 2015 at 23:54
  • 1
    I agree with Tas. Although "compile as console" is correct, it's not helpful unless you explain how to compile as console. Nov 14, 2015 at 23:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.