square program function with mingw but not with microsoft visual



  • Hallo,
    I am a new user of Microsoft visual and I am using visual 6.0. My small program which I compilled in mingw, works fine but visual basic is showing errors. I do not know why? Could anyone explain me please?

    /*program: square.c */
    #include<stdio.h>
    int main( void){
    	int x(5);
    	int res;
    	res=x*x;
    	printf("square is %d", res);
    return 0;}
    

    microsoft visual showing follwoing errors.

    Compiling...
    square.c
    e:\test\square.c(3) : error C2143: syntax error : missing ')' before 'constant'
    e:\test\square.c(3) : error C2143: syntax error : missing ';' before 'constant'
    e:\test\square.c(3) : error C2059: syntax error : ')'
    e:\test\square.c(4) : error C2143: syntax error : missing ';' before 'type'
    e:\test\square.c(5) : error C2065: 'res' : undeclared identifier
    e:\test\square.c(5) : error C2296: '*' : illegal, left operand has type 'int (__cdecl *)()'
    e:\test\square.c(5) : error C2297: '*' : illegal, right operand has type 'int (__cdecl *)()'
    Error executing cl.exe.
    
    square.obj - 7 error(s), 0 warning(s)
    


  • square.c statt swuare.cpp



  • Do you want to use C or C++? Because .c files (usually) are being compiled with a C and not with a C++ Compiler. And why are you using Visual Studio 6? It's very old and the 2010 express edition is free.



  • Warum bist du hier, aber nicht im IRC cooky? 😞



  • euklid, Visual Studio 6.0 has been released in 1998 and is known to have many bugs and incompatibilities to the C++ standard (well, it's difficult to conform to a standard before its release ;)).

    Pi, kannst du nicht woanders spammen? Für solche Dinge gibts E-Mail 🙄



  • Ich habe die Hoffnung, dass er das liest. Aber du hast natürlich Recht, das gehört nicht hier her.


Anmelden zum Antworten