Code does not run in c++visual studio

Hi, I'm new in programming. We just learned how to use functions. In my opinion, i did everything ok in my program, but the code does not run in C++ studio 2008 neither 2010. I dont know why. I used code just like in the book. I noticed that there are several types of programming languages that run in C++. For instance, the #include <stdio.h> is simply ignored in C++ i'm using. I dont wanna change my code now, so here is the question: what language should i use to run my code?
If you are using stdio.h then you are likely using C (printf, etc.)

If you are using C++ then you should be including <iostream> and using std::cout, std::cin.
Yeah, you're probably using C syntax which is on certain aspects more relaxed than C++. Though we can't know until you post code.
#include "stdafx.h"
#include<stdio.h>
#define false 0
#define true 1


int isprime(int b);

int main(void)
{
int a;

printf("Enter an integer value-->");
scanf("%d\n", &a);
printf("%d\n", isprime(a));
return 0;
}

int isprime(int b)
{
int c;
for(c=2;c<b;c++)
if(b%c!=0)
return false;
return true;



}

Here is the code. When i debug it, it executes only the first two statements. Then cursor is blinking on next line, when i type anything in it, window closes.
If i am really using C, what program is compartible with that?
Thanks
Hmm....

The problem is that your IDE isn't pausing. Read this very useful thread: http://www.cplusplus.com/forum/beginner/1988/

You are yourself unsure that you are using C?
Let me assure you that you have so far, indeed, used plain C code.

If i am really using C, what program is compatible with that?


C is almost fully compatible with C++ to some extent. That means you can compile C code in a C++ compiler.

I'm really not sure what you meant by your last question, could you elaborate?
Last edited on
Topic archived. No new replies allowed.