Thread: sudoku help

  1. #1
    Registered User
    Join Date
    Nov 2005

    sudoku help


    im trying to create a program that will open a file and read it, then check to see if it is a solution for a sudoku puzzle. so far i have....

    fstream infile; ( "good.txt", ifstream::in );
    if ( infile.is_open() == false ) {
    cout << "couldn't open " << endl;
    int i;
    int k;
    int a [9] [9];
    for (int i=0; i<9; i++)
    for (int k=0; k<9; k++)
    if (a[i][k]==k+1) 
    cout << "solved" << endl;
    cout<<"row "<<i<<" is missing "<<k+1<<endl;
    return 0;
    my problem is that it doesnt diplay what it should. its like it isnt opening the file or reading it.

    am i missing something? not sure how to have it check for a solution in a 3x3 square...any suggestionS?

  2. #2
    Registered User
    Join Date
    Apr 2003
    If the file didn't open, you would be getting your error message.

    am i missing something?
    Where do you read from the file?
    Last edited by 7stud; 11-18-2005 at 02:36 AM.

  3. #3
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Out of scope
    Throw an "ios::nocreate" flag in to that .open statement. Then check to see if it's opening.
    Sent from my iPadŽ

  4. #4
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    any suggestionS?
    Indent your code. It makes it much easier to read and debug.

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell

    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ:

    My website:
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sudoku 4 by 4 combination lister?
    By iskate4 in forum C++ Programming
    Replies: 2
    Last Post: 02-19-2009, 01:56 PM
  2. malloc, structures, arrays and sudoku!!
    By AmbliKai in forum C Programming
    Replies: 13
    Last Post: 10-15-2008, 03:05 AM
  3. sudoku - arrays
    By rocketman50 in forum C++ Programming
    Replies: 2
    Last Post: 03-21-2008, 09:20 AM
  4. Help for a sudoku Solver
    By axilleask in forum C Programming
    Replies: 3
    Last Post: 11-26-2007, 04:28 PM
  5. Sudoku - the new addiction
    By axon in forum A Brief History of
    Replies: 11
    Last Post: 11-07-2005, 11:39 PM