Have you tried running the code?
I'm pretty sure your compiler will tell you whether or not it makes sense.
Printable View
so it doesn''''t make sense
computed error
any idea???
thanks
Hi thanks for your reply
have include this in the heading. so I think it should create a mtrix with 32 X 32 ??Code:#define MATRIX_SIZE 32
This return 1 number between 100- 400 or create 100 - 400 numbers? ( I am looking to create 400 numbers)Code:int n = 100 + rand() % 300;
In this case, do i still need to keep the second for- loop?
What i was think is generate 300 numbers between 1-1024 (My Matrix "32 X 32" )
and fill 1s into this wall.
How do i place 1 into array??
thanks thanks
Well, it means your declarations of matrix and matrix_data are 32x32 yes. Your for loop just has a random [32] in it, which is a syntax error.
One number between 100 and 400.Quote:
This return 1 number between 100- 400 or create 100 - 400 numbers? ( I am looking to create 400 numbers)Code:int n = 100 + rand() % 300;
Since your second for loop is the only one that does anything at all, I would keep that one, yes.Quote:
In this case, do i still need to keep the second for- loop?
And how could that possibly help you? So if you draw the number 875, what are you going to do with it? (Yes, I know that there is a way to do something with it, but I'm betting you don't.)Quote:
What i was think is generate 300 numbers between 1-1024 (My Matrix "32 X 32" )
Not only have we told you this 23 times, you've already got it in your codeQuote:
How do i place 1 into array??
thanks thanks
This line puts 300 1's in your matrix. It does. Really. (Granted, it may overlap by putting a 1 where there was one already, but ok.) You can stop asking now, please.Code:for (x = 0; x < 300; x++) matrix_data[rand()%MATRIX_SIZE][rand()%MATRIX_SIZE] = 1;
Okay, I'll backtrack a little bit -- I noticed that your arrays are characters, not integers; so change that to int matrix_data et cetera.
Thakns for you help. Spending time on my question XXTHXXX
So I need to change all char to int??
Warning W8060 :Possibly incorrect assignment in function output_program(prog *)
Code:int matrix[MATRIX_SIZE][MATRIX_SIZE];
int matrix_data[MATRIX_SIZE][MATRIX_SIZE] = {{0}};
/////////////////////////////////unsigned srand//////////////////////////
int main() {
int x;
srand(time(0));
for (x = 0; x < 300; x++) matrix_data[rand()%MATRIX_SIZE][rand()%MATRIX_SIZE] = 1;
printf("%d\n", 1);
}
/////////////////////////////////////////////////////////////////////////
int trace_matrix[MATRIX_SIZE][MATRIX_SIZE];
void output_program(struct prog *progp)
{
char *codep = progp->code;
char token;
while (token = *codep++)
fputs(token_table[token].name, stdout);
putchar('\n');
}
void print_matrix(void)
{ int i, j; char symbs[] = " OX";
for (i=0; i < MATRIX_SIZE; i++)
{ for (j=0; j < MATRIX_SIZE; j++)
putchar(symbs[trace_matrix[i][j]]);
putchar('\n');
}
}
void skip_arg(void)
{ int count = 0;
while ((count += token_table[*nodep++].arity_sub1) >= 0) ;
}
Still error.... sorry to be a pain....
Error E2171 antsimple2.cpp 646: Body has been defined for function 'main<>'
so i assue error on the followinf code
I have change char to int. this is the only error occur at the moment.Code:int main() {
int x;
srand(time(0));
for (x = 0; x < 300; x++) matrix_data[rand()%MATRIX_SIZE][rand()%MATRIX_SIZE] = 1;
printf("%d\n", 1);
}
What else i need to modify???
thanks thanks
If you're getting that error now, you got that error before -- this means you have another int main() somewhere up above. You need to only have one main().
yes you r right.
I have tried change the name or place it inside the origianl int main()
however error still occuring
Error 713: Compound statement missing
what this mean??
cheerrrrs
this function keep occur error.Code:void output_program(struct prog *progp)
{
char *codep = progp->code;
int token;
while (token = *codep++)
fputs(token_table[token].name, stdout);
putchar('\n');
}
I think I may missing the statement to put 1's?
or it is completely differetn thing?