Click here to Skip to main content
15,884,677 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: sudoku runtime error help please !!!!! Pin
Maximilien10-Apr-09 15:04
Maximilien10-Apr-09 15:04 
QuestionRe: sudoku runtime error help please !!!!! Pin
David Crow10-Apr-09 17:12
David Crow10-Apr-09 17:12 
AnswerRe: sudoku runtime error help please !!!!! [modified] Pin
tayyyar10-Apr-09 17:59
tayyyar10-Apr-09 17:59 
GeneralRe: sudoku runtime error help please !!!!! Pin
Cedric Moonen10-Apr-09 22:09
Cedric Moonen10-Apr-09 22:09 
GeneralRe: sudoku runtime error help please !!!!! Pin
tayyyar11-Apr-09 1:35
tayyyar11-Apr-09 1:35 
GeneralRe: sudoku runtime error help please !!!!! Pin
David Crow13-Apr-09 3:28
David Crow13-Apr-09 3:28 
QuestionRe: sudoku runtime error help please !!!!! Pin
David Crow13-Apr-09 3:32
David Crow13-Apr-09 3:32 
AnswerRe: sudoku runtime error help please !!!!! Pin
Sauce!12-Apr-09 6:03
Sauce!12-Apr-09 6:03 
I've gone through and formatted your code for easier reading for the sake of everyone else's sanity. Please make proper use of tabs and whitespace. Whitespace is ESPECIALLY needed between operators and after comma's (,) I've also added some comments where I think you've made simple mistakes that probably don't affect the problem you're having but are otherwise problems waiting to happen. Most of the changes are however cosmetic in nature.

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

#define size 9     //Don't use #define for your constants. Instead use the const keyword and the desired type of the object you are creating.
#define size2 81

int checkingSquare(int *i, int *j, int *row, int *column, int **a);

int main()
{
     int i, j, row, column, controller = 0; //Only controller is being initialised to zero here. 
     int **a = 0;

     srand(time(NULL));
     for(i = 1; i < 10; i++)
     {//start for1 NOTE: there is no need to place comments like this showing which braces match
      //up if you have properly formatted your code with indentations like I have done for you.     
          for(j = 1; j < 10; j++)
          {//start for2
               while(controller == 0)
               {
                    printf("access1");
                    controller = checkingSquare(&i, &j, &row, &column, a);
               }
          }//end for 2

     }//end for 1

     for(i=1;i<10;i++)
     {
          for(j=1;j<10;j++)
          {
               printf("%d\n",a[i][j]);
          }
     }
     return 0;
}

void square(int *inte, int *inte2, int *row, int *column)
{
     *row = *inte / 3;
     if(*row != 1)
     {
          *row++;
     }
     *column=*inte2 / 3;

     if(*column != 1)
     {
          *column++;
     }
}

int checkingSquare(int *i, int *j, int *row, int *column, int **f)
{
     int x, y;
     *(*(f + *i) + *j) = rand() % 9 + 1; //Terrible code. Very hard to read. Not to mention when debugging you are causing an access violation 
                                         //when code execution reaches this line. This is probably where your problem lies. I suggest you learn
                                         // to use your debugger as this is something that should have taken you about 30 seconds to spot.
     printf("access");

     //checkin big squares
     square(i, j, row, column); //to determine which big square we are in
     for(x = (*row * 3 - 2); x < (*row * 3 + 1); x++)
     {
          for(y = *column * 3 - 2; y < *column * 3 + 1; y++)
          {
               if(f[x][y] == f[*i][*j])
               {
                    return 0;
               }
          }
     }

     //checkin sides
     for(x = 1; x < 10; x++)
     {
          if(f[x][*j] == f[*i][*j])
          {
               return 0;
          }
     }

     for(y = 1; y < 10; y++)
     {
          if(f[*i][y] == f[*i][*j])
          {
               return 0;
          }
     }

return 1; //common convention is to return ZERO (0) at the end of int main(). 
//The program that ran your program may or may not interpret the value you return,
// but in the case that it does, it may mis-interpret the 1 you have returned as an error. 
}

Questionhow to control Stepper Motor Control driver through serial Port Pin
sahih10-Apr-09 6:01
sahih10-Apr-09 6:01 
AnswerRe: how to control Stepper Motor Control driver through serial Port Pin
CPallini10-Apr-09 6:49
mveCPallini10-Apr-09 6:49 
AnswerRe: how to control Stepper Motor Control driver through serial Port Pin
Rajesh R Subramanian11-Apr-09 0:15
professionalRajesh R Subramanian11-Apr-09 0:15 
QuestionCreateFile help Pin
suendisra10-Apr-09 6:00
suendisra10-Apr-09 6:00 
QuestionPen Dive Recovery Pin
simash10-Apr-09 5:10
simash10-Apr-09 5:10 
AnswerRe: Pen Dive Recovery Pin
Rajesh R Subramanian10-Apr-09 21:22
professionalRajesh R Subramanian10-Apr-09 21:22 
QuestionOrganizing my program in classes? And question about registry information retrieval. Pin
rbwest8610-Apr-09 4:52
rbwest8610-Apr-09 4:52 
QuestionRe: Organizing my program in classes? And question about registry information retrieval. Pin
David Crow10-Apr-09 5:00
David Crow10-Apr-09 5:00 
AnswerRe: Organizing my program in classes? And question about registry information retrieval. Pin
led mike10-Apr-09 5:27
led mike10-Apr-09 5:27 
Questionwhat is patches Pin
ashish8patil10-Apr-09 2:36
ashish8patil10-Apr-09 2:36 
AnswerRe: what is patches Pin
David Crow10-Apr-09 2:47
David Crow10-Apr-09 2:47 
AnswerRe: what is patches Pin
Eytukan10-Apr-09 4:12
Eytukan10-Apr-09 4:12 
GeneralRe: what is patches Pin
jeron110-Apr-09 4:25
jeron110-Apr-09 4:25 
Answerwhat is google Pin
led mike10-Apr-09 4:28
led mike10-Apr-09 4:28 
Questionwhat is wsusscan.cab Pin
ashish8patil10-Apr-09 2:34
ashish8patil10-Apr-09 2:34 
AnswerRe: what is wsusscan.cab Pin
David Crow10-Apr-09 2:49
David Crow10-Apr-09 2:49 
QuestionOpen File Dialog Pin
nonokey10-Apr-09 2:08
nonokey10-Apr-09 2:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.