i am trying to compile it (ms visual c++) but it is not compiling, i guess there is some errors but visual c++ is only saying fatal error which i have no idea what it is.Any idea?

#include "stdafx.h"
#include <iostream>
using namespace std;
      int nbs=0;
   
      void Queens(int nn, int row[], int k=0)
   
      { if(k==nn)
   
      { cout<<endl<<"Solution "<<(++nbs)<<":"<<endl;
   
      for(int i=0; i<nn; i++)
   
      { for(int j=0; j<nn;j++)
   
      { if(row[i]==j) cout<<("Q "); else cout<<(". ");
   
      } cout<<endl;} cout<<endl;}
   
      else
  
      { for(int i=0; i<nn; i++)
  
      { row[k]=i;
  
      for(int j=0; j<k;j++)
  
      { if((row[j]==row[k])||((row[j]-row[k])==(k-j))
  
      ||((row[k]-row[j])==(k-j))) goto fails;
  
      } Queens(nn, row, k+1); fails:;}}
  
      }
  
      int qu_main(int argc, char *argv[])
  
      { const int nn = 8;
  
      int *row = new int[nn];
  
      Queens(nn, row);
  
      return 0;
  
      }

well i got it running. i deleted the #include "stdafx.h" and changed qu_main(argc, argv) to int main()

#include "stdafx.h" is mendetory if you are debugging with microsoft visual studio but yes if you are using other debugger such as venus then you dont need that.BTW yeah it ran after i changed it to int main().. thank you a lot.

i use windows and when you create a new win 32 app all you have to do is tell it not to precomplie the headers and use an empty project. this way you get and empty project and can do whatever you want. i never use stdafx.h unless i need it.

Hats off to you boss but i guess that is not my cup of tea .. i am happy with visual studio :)

i use windows and when you create a new win 32 app all you have to do is tell it not to precomplie the headers and use an empty project. this way you get and empty project and can do whatever you want. i never use stdafx.h unless i need it.

sorry i used the wrong word. i use Microsoft visual studio professional 2005 and you can write win 32 console apps without using stdafx.h all you have to tell it is to make an empty project and not to use the precompiled headers. its more of a matter that i want total control and not that there is anything wrong with what they give you to start with.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.