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 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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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...
|
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...
|
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=
|
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...
|
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...
|
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...
|
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...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
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...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
| |