By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,655 Members | 959 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,655 IT Pros & Developers. It's quick & easy.

how i can put 2d array to a pointer

P: 6
how i can put 2d array to a pointer? In the below program i am giving a first value to output_bit and then start to a loop and putting the new values to an another array as called newdata[l][k]. But as i understand from this loop the last value of the 2d array u[l][k] is not put to newdata[l][k]. Because of the first value of output_bit which is given in he beginning. In 1d array it is easy to solve this problem that you can put output_bit data in the for loop to the new data as newdata[k-1] but 2d array it is not possible to do this. So how can i solve this problem?????? Thanks for your interest.....



output_bit=0
for (l = 0; l < K; l++) {
for (k = 0; k < K; k++) {
if (u[l][k] == 0)
output_bit =1 - output_bit;
newdata[l][k] = output_bit;
}}
Nov 7 '06 #1
Share this Question
Share on Google+
2 Replies


P: 6
how i can put 2d array to a pointer? In the below program i am giving a first value to output_bit and then start to a loop and putting the new values to an another array as called newdata[l][k]. But as i understand from this loop the last value of the 2d array u[l][k] is not put to newdata[l][k]. Because of the first value of output_bit which is given in he beginning. In 1d array it is easy to solve this problem that you can put output_bit data in the for loop to the new data as newdata[k-1] but 2d array it is not possible to do this. So how can i solve this problem?????? Thanks for your interest.....



output_bit=0
for (l = 0; l < K; l++) {
for (k = 0; k < K; k++) {
if (u[l][k] == 0)
output_bit =1 - output_bit;
newdata[l][k] = output_bit;
}}
Nov 7 '06 #2

Banfa
Expert Mod 5K+
P: 8,916
Please don't double post.

Your question is not clear, assuming that K is the size of both dmensions of the array then the code posted writes all of newdata for which u is non-zero including the last entry newdata[K-1][K-1]
Nov 7 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.