:-/I'm getting the following error when I debug this small test programm . I can't find anything wrong with it. Even on MSDN they come up with a two line sample code which generates that fault code. In other words, they have no clue either. I hope that some one can help me to solve this weird problem. I'm using VS 2008 Express. Hier is the code:

#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <stdio.h>

using namespace std;

int a=10;
int b=10;


int main();

{
    c=printf(a*b);

    scanf(char);

    return(0);
}

Edited 3 Years Ago by Reverend Jim: Fixed formatting

I'm getting the following error when I debug this small test programm . I can't find anything wrong with it. Even on MSDN they come up with a two line sample code which generates that fault code. In other words, they have no clue either. I hope that some one can help me to solve this weird problem. I'm using VS 2008 Express. Hier is the code:

#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <stdio.h>

using namespace std;

int a=10;
int b=10;


int main();

{
    c=printf(a*b);

    scanf(char);

    return(0);
} 

end quote.

You should use code tags.

And, my friend, its not working because you seem to be mixing C and C++ together. You have included <iostream>, so use cout ;).

Edited 3 Years Ago by mike_2000_17: Fixed formatting

I can't find anything wrong with it.

Never mind the fact that it doesn't compile, you have the syntax for printf and scanf completely wrong, and least of all it's some C/C++ hybrid program...

For better or worse, the compiler is usually right.

:-/I'm getting the following error when I debug this small test programm . I can't find anything wrong with it. Even on MSDN they come up with a two line sample code which generates that fault code. In other words, they have no clue either. I hope that some one can help me to solve this weird problem. I'm using VS 2008 Express. Hier is the code:

#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <stdio.h>

using namespace std;

int a=10;
int b=10;


int main();

{
c=printf(a*b);

scanf(char);

return(0);
}

I modified your program so it works under linux, maybe it will work under your platform. I hope it will help you.

#include <stdlib.h>
#include <stdio.h>

using namespace std;

int a = 10;
int b = 10;

int main()
{
    // print it!
    int i = printf("%d", a*b);

    // check for a correct printing
    if(i == 0)
           return(EXIT_FAILURE);

    // pause
    getchar();

    return(EXIT_SUCCESS);
}

I modified your program so it works under linux, maybe it will work under your platform. I hope it will help you.

#include <stdlib.h>
#include <stdio.h>

using namespace std;

int a = 10;
int b = 10;

int main()
{
    // print it!
    int i = printf("%d", a*b);

    // check for a correct printing
    if(i == 0)
           return(EXIT_FAILURE);

    // pause
    getchar();

    return(EXIT_SUCCESS);
}

Thank you for your helpfull reply. I just entered the above code but it gave me the same error code. Even if I don't put a function between the man() declaration hooks {} but just a simple line like this: int a=10; it results to the same error code. There is nothing spectacular written in my code, it is just bare. It still can't be compiled with the Microsoft compiler.

I hope it is not related to Microsoft's very large list of buggy applications.

Anyway thanks again for your help, I hope to solve it one day.
Have a nice 2010.

No, your problem is that you don't know whether you're writing C OR C++.

Some random bag of syntax from both languages just doesn't cut it.

Tell us which language you're ACTUALLY interested in learning, and we can guide you appropriately.

No, your problem is that you don't know whether you're writing C OR C++.

Some random bag of syntax from both languages just doesn't cut it.

Tell us which language you're ACTUALLY interested in learning, and we can guide you appropriately.

Can you tell me where the C code and the C++ code resides in my code? And Im interested to go deeper into C++, but up until now
if it is not even posible to write a very simple peace of code like:

#include <includefile>

int main()


{
int a=10;

return(0);
}


without a bunch of not to the point error codes then I wonder if it is not my OS (Win 7) cousing the bother. Anyway I hope somebody will
proof me wrong.

Than very much for your reply.

Marcel

Try this :

#include<iostream>

using namespace std;

int main(){
  cout << "Hello World\n";
  return 0;
}

Thanks again. I will try the code but I going to re-install visual C++ 2008 first and start all afresh. I will come back in a while.

Marcel

Thanks again. I will try the code but I going to re-install visual C++ 2008 first and start all afresh. I will come back in a while.

Marcel

Well, I re-installed Visual C++ 2008 after I made sure that all the traces from the former install had disappeared. I started with a new project ( win32, empty project) and entered the code in the sheet. When I debugged it I've got a new error message:

error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup

I have no idea what the problem is this time. I done nothing special and just tried to compile the code in a new install. I hope somebody
knows what is wrong this time. I know, patience is the word and for the time being I will stick it out.

This article has been dead for over six months. Start a new discussion instead.