Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


C programming help

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
dkimxd
Master Cheater
Reputation: 0

Joined: 22 Nov 2006
Posts: 437
Location: 11

PostPosted: Mon Dec 01, 2008 5:03 pm    Post subject: C programming help Reply with quote

I'm trying to work on some homework for class and I don't understand what I am supposed to do. Here is the assignment:

Code:
By using a pointer to pointer **A and the function malloc()
allocate the memory for the 4x4 matrix A[][]. By using a pointer *b
and the function malloc() allocate the memory for the 4-dimensional vector
b[]. Read the components of A and b from the given input file matrix.dat.
The last line of the input file contains the components of b. The rows of
matrix A are the first four lines of the input file. Print the components
of A[][] row by row, and the components of b[]. Using the function gauss()
given in the lecture notes week9.txt, solve the system of linear algebraic
equations A[][]*x[]=b[]. Print the components of the solution vector x[].
Calculate and print the length of this vector. Free the allocated memory.


errr... yeah. help if you can please. Smile


is the pointer **A the same thing as the component A?

_________________
My siggy makes me look 1337
Back to top
View user's profile Send private message
Jani
Grandmaster Cheater
Reputation: 2

Joined: 29 Dec 2006
Posts: 804

PostPosted: Tue Dec 02, 2008 2:18 am    Post subject: Re: C programming help Reply with quote

dkimxd wrote:
is the pointer **A the same thing as the component A?
Pointer points to a memory location where the data is stored. Eg. in this case there's a block of 4x4 = 16 components, which you should read from the file and then fill the matrix with them. Having two dimensional pointers just means that there's pointers to pointers, which point to the data. So yea, if you **A can be the same as the FIRST component of the matrix, since * is the dereference operator. Just experiment with pointers and you'll find them handy, here's an example:
Code:
int C = 10;
int *B = &C;
int **A = &B;
printf("C:%x->%d\nB:%x->%x->%d\nA:%x->%x->%x->%d", &C, C, &B, B, *B, &A, A, *A, **A);

Output:
C:13ff60->10
B:13ff54->13ff60->10
A:13ff48->13ff54->13ff60->10


See eg.: http://www.cplusplus.com/doc/tutorial/pointers.html

EDIT: ah hah, I just came across with this: http://www.youtube.com/watch?v=UvoHwFvAvQE there's a nice tutorial :D
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites