2 registered members (TipmyPip, 1 invisible),
18,731
guests, and 7
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Script Crash
[Re: Uhrwerk]
#411527
11/17/12 15:11
11/17/12 15:11
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
It sure does support indirection mutliple times:
#include <acknex.h>
int i = 0;
void main()
{
int* p1 = &i;
int** p2 = &p1;
(*(*p2)) = 1337;
printf("%d",i);
}
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: Script Crash
[Re: Uhrwerk]
#411534
11/17/12 15:22
11/17/12 15:22
|
Joined: Nov 2011
Posts: 139 India
Yashas
OP
Member
|
OP
Member
Joined: Nov 2011
Posts: 139
India
|
That is wrong. SpeedRun_Time is a pointer. You write the address 60 to that pointer. What you intended to do was setting the integer value SpeedRun_Time was pointing to, right? Exactly, so I shud *SpeedRun_Time = 60; right?? And thats really not funny of the compiler (  ) to show crash in so and so but it isn't the crash there(Many might not be knowing :D) and it's the line preceding the function call. 
|
|
|
Re: Script Crash
[Re: Yashas]
#411537
11/17/12 15:25
11/17/12 15:25
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
Have you initialized your pointer?
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: Script Crash
[Re: Yashas]
#411538
11/17/12 15:28
11/17/12 15:28
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
The compiler has already done all of its work at that time, so you can't blame him.  In general: There might be scenarios where writing an address to pointer is valid. The most basic usage of this is "MyPointer = NULL". That is basically the same. This is one of the unlucky cases where you encounter errors previously done much later - or never at all. EDIT: @JustSid: He did.
Always learn from history, to be sure you make the same mistakes again...
|
|
|
Re: Script Crash
[Re: Uhrwerk]
#411548
11/17/12 16:01
11/17/12 16:01
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
Oh god, I totally ignored the first post. Ashes on my head.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: Script Crash
[Re: Yashas]
#411554
11/17/12 16:33
11/17/12 16:33
|
Joined: Jun 2009
Posts: 2,210 Bavaria, Germany
Kartoffel
Expert
|
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
All C books show " *variable = value;" but that dint work. it should work:
#include <acknex.h>
void main()
{
int * int_ptr_to_mem = sys_malloc(sizeof(int));
*int_ptr_to_mem = 1234; // >> *variable = value; <<
int output = *int_ptr_to_mem; // printf doesn't work with pointers as value
printf("int_ptr_to_mem = %.0f", (double)output);
}
...works fine for me 
POTATO-MAN saves the day! - Random
|
|
|
Re: Script Crash
[Re: Kartoffel]
#411556
11/17/12 17:15
11/17/12 17:15
|
Joined: Jan 2002
Posts: 4,225 Germany / Essen
Uhrwerk
Expert
|
Expert
Joined: Jan 2002
Posts: 4,225
Germany / Essen
|
You can of course diretly use printf.
#include <acknex.h>
void main()
{
int * int_ptr_to_mem = sys_malloc(sizeof(int));
*int_ptr_to_mem = 1234; // >> *variable = value; <<
printf("int_ptr_to_mem = %d",*int_ptr_to_mem);
printf("address of int_ptr_to_mem = %p",int_ptr_to_mem);
ptr_remove(int_ptr_to_mem);
}
Last edited by Uhrwerk; 11/17/12 17:18. Reason: of course vs. of cause. *grrrrr*
Always learn from history, to be sure you make the same mistakes again...
|
|
|
|