473,382 Members | 1,078 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

what wrong with this:

im doing the following:

int _tmain(int argc, _TCHAR* argv[])

{

typedef double matrix4x4[4][4];

matrix4x4 *mat = (matrix4x4*)malloc(sizeof(matrix4x4));

for(int i=0;i<4;i++)

{

for(int j=0;j<4;j++)

{

if(i==j) *mat[i][j] = 1;

else *mat[i][j] = 0;
}
//printf("\n");

}
for(int i=0;i<4;i++)

{

for(int j=0;j<4;j++)

{

printf("%f ", *mat[i][j]);

}

printf("\n");

}

return 0;

}

and it does not work. it works on another computer but not mine.
but if i put in the printf("\n") that i have comented out, it works just fine.
why? I get acess vioalation. The debugger shows something like this:
*mat ..... double[4][4]
*mat[i] .... double[4]
*mat[i][j] double
....
mat double[4][4]*
mat[i] double[4][4] //this does not seem correct
mat[i][j] double[4] //this does not seem correct

can anyone help me?

thor andreas
Jul 22 '05 #1
1 1161
Bad precedence, see corrections below.

"Thorsan" <th*****@stud.ntnu.no> wrote in message
news:65**************************@posting.google.c om...
im doing the following:

int _tmain(int argc, _TCHAR* argv[])

{

typedef double matrix4x4[4][4];

matrix4x4 *mat = (matrix4x4*)malloc(sizeof(matrix4x4));

for(int i=0;i<4;i++)

{

for(int j=0;j<4;j++)

{

if(i==j) *mat[i][j] = 1;

else *mat[i][j] = 0;
if (i == j) (*mat)[i][j] = 1;
else (*mat)[i][j] == 0;
}
//printf("\n");

}
for(int i=0;i<4;i++)

{

for(int j=0;j<4;j++)

{

printf("%f ", *mat[i][j]);
printf("%f ", (*mat)[i][j]);

}

printf("\n");

}

return 0;

}


john
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mike Henley | last post by:
I first came across rebol a while ago; it seemed interesting but then i was put off by its proprietary nature, although the core of the language is a free download. Recently however, i can't...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
9
by: Pyenos | last post by:
import cPickle, shelve could someone tell me what things are wrong with my code? class progress: PROGRESS_TABLE_ACTIONS= DEFAULT_PROGRESS_DATA_FILE="progress_data" PROGRESS_OUTCOMES=
3
by: Siong.Ong | last post by:
Dear all, my PHP aims to update a MySQL database by selecting record one by one and modify then save. Here are my PHP, but I found that it doesnt work as it supposed to be, for example, when...
24
by: MU | last post by:
Hello I have some code that sets a dropdownlist control with a parameter from the querystring. However, when the querystring is empty, I get an error. Here is my code: Protected Sub...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.