try:
gotoxy(r,c);
printf("*");
try:
gotoxy(r,c);
printf("*");
does it have anything to do with storing the memory location?
While that may work, I dont think I can really use it because I havent learned anything like that. But i'll look through the book quick and see if it is anywhere, then I could use it.Originally Posted by qqqqxxxx
EDIT: actually I just remembered at the beginning of the semester they said we could not use goto statements.
gotoxy can be used for positioning the cursor at (r,c)
but it is non standard.
do you think there is any other way to do it?Originally Posted by qqqqxxxx
This is what I got, I know its wrong, but is there something I could change to make it work?
Code:int size=0; for(r=0;r<25;r++){ if(image[r]==1){ size++; } } for (r = 0; r < size; r++) { for (c = 0; c < size; c++) { if(image[r+c*size] == 1){ printf("*"); } } }
I just wanted to get this straight because Im not so sure. The drawImage function is creating a square of 1s right? Because when I try out the program with the function I added, it just ends after asking for the size of square I want. Basically I think its implying that no element in the array equals 1 (in my printImage function).
EDIT: if this helps this is all I have:
Code:#include <stdio.h> #include "drawImage.h" /*function prototypes*/ void printImage(int image[]); void edgeDetection(int image[], int edge[]); /*function main begins program execution*/ int main (){ int side; int square[625]; int i, even; printf("Please enter the size of the square you would like to draw" "\n(maximum size is 23):"); /*print statement*/ scanf("%d",&side); for(i = 0; i < 625; i ++){ square[i] = 0; } even = (side & 1); drawImage(square, 25, side, even); printImage(square); if(side>23){ printf("The size of the square cannot be larger than 23, please start again\n"); return 0; } /*end if*/ return 0; /*indicate program ended successfully*/ } /*end function main*/ void printImage(int image[]){ int r, c; int size=0; for(r=0;r<25;r++){ if(image[r]==1){ size++; } } for (r = 0; r < size; r++) { for (c = 0; c < size; c++) { if(image[r+c*size] == 1){ printf("*"); } } } }
so when u use this size in the rest of your program,it doesnt traverse through the whole array.Code:int size=0; for(r=0;r<25;r++){ if(image[r]==1){ size++; } }
>printf("*");
u wont get a square,because u have to set the cursor at the correct position first.
Well here I am just trying to get the length of the square. I was thinking all I needed was the length of a side. Am I wrong?Originally Posted by qqqqxxxx
the problem is u have still not understood the assignment well and neither have i.
go through the drawimage function.
make sure u understand what is going on inside it.
then think of the printimage function.
so,
image array defines the canvas.
and the square is loacted in the center of the canvas.
Last edited by qqqqxxxx; 03-23-2006 at 03:17 AM.
This is true, I am not really understanding the assignment well. I think I understood the part about the canvas and the square being in the center of the canvas, but Im just not understanding how it really works and how my functions should work. I guess Ill just give it some more thought. Thanks for your help though.Originally Posted by qqqqxxxx
int size=0;
for(r=0;r<25;r++){
if(image[r]==1){
size++;
}
}
sorry, this will give u the side,but u already know the side.Code:
but the side hasnt been passed on to this function. so this is needed right?Originally Posted by qqqqxxxx
and i tried running your program,the printimage function is working.
well, no, the program is just ending after the user prompt to enter the desired size. This is why I was trying to understand drawImage better.Originally Posted by qqqqxxxx
Its working? When I enter the size I want, the program just ends without any warnings or anything. But, it doesnt print anything.Originally Posted by qqqqxxxx