Click here to Skip to main content
15,889,595 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Why does this code work inc++shell(you have to change line 4 to "main(int)" for it to run) but crashes when ran through dev c++?


C++
#include<iostream>
using namespace std;

main()
{

    int primes,count=0,remNum=2,current=2;
    cout<<"how many primes can i find for you?";
    cin>>primes;
    while(count<primes)
    { 
        if(current=remNum)
        {
           cout<<current<<endl;
           current++;
           remnum=2;
           count++;
           if(current%remnum=0)
           {

           }
           remnum++;
           return 0;
       }


What I have tried:

copy and pasting it and recompiling it in dev c++, other programs run. and before if there was a never ending loop it would just flash and never finish until you closed. this one says the exe has stopped working
Posted
Updated 3-Dec-16 21:29pm
v3
Comments
Richard MacCutchan 4-Dec-16 3:25am    
I have edited your question to try and correct the formatting but it still looks a bit strange. Please check the if statements as I suspect they should contain a double '=' sign.

1 solution

Probably the cut'n'paste was unfortunate, for
C
if(current=remNum)

it is a mistake (you should have used the == operator).
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900