Click here to Skip to main content
15,923,120 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: static text in mfc Pin
Jijo.Raj9-Mar-09 19:39
Jijo.Raj9-Mar-09 19:39 
AnswerRe: static text in mfc Pin
Hamid_RT9-Mar-09 20:00
Hamid_RT9-Mar-09 20:00 
JokeRe: static text in mfc Pin
Iain Clarke, Warrior Programmer10-Mar-09 1:14
Iain Clarke, Warrior Programmer10-Mar-09 1:14 
GeneralRe: static text in mfc Pin
Hamid_RT10-Mar-09 2:12
Hamid_RT10-Mar-09 2:12 
QuestionGetDesktopWindow() Pin
sam_psycho9-Mar-09 18:01
sam_psycho9-Mar-09 18:01 
AnswerRe: GetDesktopWindow() Pin
«_Superman_»9-Mar-09 18:22
professional«_Superman_»9-Mar-09 18:22 
GeneralRe: GetDesktopWindow() Pin
sam_psycho9-Mar-09 20:59
sam_psycho9-Mar-09 20:59 
QuestionHelp with printing structures Pin
Pennycakes9-Mar-09 16:21
Pennycakes9-Mar-09 16:21 
I am trying to get this program to work. It is only the first part of a Sudoku assignment but everything works until it goes to print out. I try to compile it and get an error when it gets to printing the structure. Help please asap!

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

struct grid{
       int row;
       int col;
};

void readArray(struct grid *z);
void printArray(struct grid y); 
       



main(){       
       struct grid x;
       x.row = 0;
       x.col = 0;
       
       readArray(&x);
       printArray(x);
       
       system ("pause"); // execute M$-DOS' pause command
       return 0;       
       }
       


void readArray (struct grid *z){
     
     int i;
     int gridRow;
     int gridCol;
     int area;
     
     z->row = 0;
     z->col = 0;

     while(z->row <= 0){
        printf("Enter the number of rows in each box.  Number must be positive.\n");
        scanf("%d", &(z->row));  // scan number into row integer
        }  // end while for rows

     while(z->col <= 0){  // while loop to get input from user for number of columns
        printf("Enter the number of columns in each box.  Number must be positive.\n");
        scanf("%d", &(z->col));  // scan number into column integer
        }  // end while loop for columns
                        
    gridRow = (z->row)*(z->col); // sets up each individual box amount
    gridCol = gridRow;  // sets up the boxes
    area = gridRow * gridCol;  // sets up the whole puzzle amount
    
    struct grid *xPtr = NULL;
    
    xPtr = (struct grid *)malloc(sizeof(struct grid));   // allocate memory needed for the array
    if(xPtr == NULL){  // if statement checking if malloc returned NULL
               printf("Error, could not allocate enough memory. Exiting program.\n");
               exit(-1);
               }  // end if statement
               
    printf("Enter numbers you want in the puzzle.\n", area); // ask user to input array numbers
    
    for(i=0; i               scanf("%d", &((xPtr)[i]));
               }  // end for loop
               
               
} // end readArray subroutine



void printArray (struct grid y){
    int rows;
    int cols;
    

    rows = y.row * y.col;  // multiply the rows and columns to get big puzzle
    cols = rows;

    if((y.row<=0) || (y.col<=0)){
      printf("printArray error: one or more of the entered dimensions is less than or equal to zero.\n");
      return;
      }
      
    int i, j, k;   

    for(j=0;j<rows;j++){>
      if ((j%y.row) == 0){
         for(i=0;i<(5*cols+(cols/y.col)+1);i++){
            printf("-");
          }
         printf("\n");
      }

      for(i=0;i<cols;i++){>
         k = j*rows + i;
         if ((i%y.col)==0){
            printf("|");
         }
         if(y[k] == 0){
            printf("    ");
            }
         else{
            printf("%3d  ",y[k]);
         }
      }
      printf("|\n");
   }
   for(i=0;i<(5*cols+(cols/y.col)+1);i++){
      printf("-");
   }
   printf("\n");
}
</stdlib.h></stdio.h>

AnswerRe: Help with printing structures - modify question please. Pin
Iain Clarke, Warrior Programmer10-Mar-09 1:18
Iain Clarke, Warrior Programmer10-Mar-09 1:18 
GeneralRe: Help with printing structures - modify question please. Pin
Pennycakes23-Mar-09 9:59
Pennycakes23-Mar-09 9:59 
QuestionScroll Bars Pin
BobInNJ9-Mar-09 15:08
BobInNJ9-Mar-09 15:08 
AnswerRe: Scroll Bars Pin
BobInNJ9-Mar-09 16:18
BobInNJ9-Mar-09 16:18 
AnswerRe: Scroll Bars Pin
Iain Clarke, Warrior Programmer10-Mar-09 1:27
Iain Clarke, Warrior Programmer10-Mar-09 1:27 
GeneralRe: Scroll Bars Pin
BobInNJ10-Mar-09 4:19
BobInNJ10-Mar-09 4:19 
QuestionC HELP PLEASE!! [modified] Pin
posidonofthecode9-Mar-09 13:55
posidonofthecode9-Mar-09 13:55 
AnswerRe: C HELP PLEASE!! Pin
BobInNJ9-Mar-09 14:14
BobInNJ9-Mar-09 14:14 
GeneralRe: C HELP PLEASE!! Pin
posidonofthecode9-Mar-09 14:41
posidonofthecode9-Mar-09 14:41 
GeneralRe: C HELP PLEASE!! Pin
BobInNJ9-Mar-09 15:07
BobInNJ9-Mar-09 15:07 
AnswerRe: C HELP PLEASE!! Pin
David Crow9-Mar-09 15:58
David Crow9-Mar-09 15:58 
QuestionVBasic to VC++ syntax conversion Pin
Software20079-Mar-09 11:20
Software20079-Mar-09 11:20 
AnswerRe: VBasic to VC++ syntax conversion Pin
0x3c09-Mar-09 11:48
0x3c09-Mar-09 11:48 
GeneralRe: VBasic to VC++ syntax conversion Pin
Software20079-Mar-09 14:51
Software20079-Mar-09 14:51 
QuestionApplication Type - DLL Pin
su_penguin9-Mar-09 10:59
su_penguin9-Mar-09 10:59 
AnswerRe: Application Type - DLL Pin
su_penguin9-Mar-09 11:03
su_penguin9-Mar-09 11:03 
GeneralRe: Application Type - DLL Pin
su_penguin9-Mar-09 11:40
su_penguin9-Mar-09 11:40 

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.