2 registered members (Akow, tomaslolo),
1,536
guests, and 12
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: What's stopping you from actually learning programming?
[Re: 3run]
#452869
06/29/15 14:03
06/29/15 14:03
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
User
|
User
Joined: Mar 2012
Posts: 927
cyberspace
|
http://boredzo.org/pointers/"bzzzt" not able to check on my laptop now , but assuming differences between c and c++ ,are also something you might want to look at. wil check out your example later.
Last edited by Wjbender; 06/29/15 14:07. Reason: bloody mistypes
Compulsive compiler
|
|
|
Re: What's stopping you from actually learning programming?
[Re: Wjbender]
#452871
06/29/15 14:56
06/29/15 14:56
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
User
|
User
Joined: Mar 2012
Posts: 927
cyberspace
|
okay so heres what's up .
throw away the debug_var
and
try
printf("%d %d %d",(long)*p,(long)*p2,(long)*p3);
Compulsive compiler
|
|
|
Re: What's stopping you from actually learning programming?
[Re: Wjbender]
#452875
06/29/15 15:40
06/29/15 15:40
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
Senior Expert
|
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
Thank you for pointing this out! So I guess we've found just another bug? BTW, it works without typecasting, I mean without (long), while manual says that's it important to typecast var to double or long.. Anyway why it's needed? Best regards
|
|
|
Re: What's stopping you from actually learning programming?
[Re: 3run]
#452881
06/29/15 16:18
06/29/15 16:18
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
User
|
User
Joined: Mar 2012
Posts: 927
cyberspace
|
I think it would be beneficial to mention or ask Jcl about debug_var , I have no idea how it works (formatting and types/pointers/adresses) , I tried applying type casting inside of debug_var to no avail so I am guessing it casts or something in thw function itself (no idea)
I guess some formatting parameter support for debug_var would be cool ,since it outputs in text anyway !!
Compulsive compiler
|
|
|
Re: What's stopping you from actually learning programming?
[Re: 3run]
#452905
06/29/15 22:15
06/29/15 22:15
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
User
|
User
Joined: Mar 2012
Posts: 927
cyberspace
|
Thank you for pointing this out! BTW, it works without typecasting, I mean without (long), while manual says that's it important to typecast var to double or long.. Anyway why it's needed? Best regards well , gamestudio automatically converts most variables of type var , to most of the correct needed types , however the var type itself is different as you know , the "var" type is almost an all rounder in litec , it can be a number a handle a pointer , as a number it could become an int or whatever automatically done by gamestudio where it knows the type it has to be casted/converted to , however this particular case i took it as ,implicitly instructing /controlling the type , because functions like printf can support multiple types it wouldn't be obvious to the engine what type I need , I have to tell it exactly what I want. in this case there were no actual "var" instead there were purely "int" types used , but "int" and "long" are also much the same thing , but printf accepts char* , int , and double no var or float support for arguments (according to manual) so therefore you need to typecast "var" to long for integers and double for non-integers explicitly . I really did not need to cast , just a habbit which I dragged along with me ,because of the var type I had to get used to , and it stuck ,that plus to me %I make sense more than %d..
Compulsive compiler
|
|
|
Re: What's stopping you from actually learning programming?
[Re: Wjbender]
#452913
06/30/15 10:05
06/30/15 10:05
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
Senior Expert
|
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
Thank you very much for such a clear explanation Now it's time to continue my journey with c# My best regards!
|
|
|
Re: What's stopping you from actually learning programming?
[Re: 3run]
#452916
06/30/15 12:55
06/30/15 12:55
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
User
|
User
Joined: Mar 2012
Posts: 927
cyberspace
|
I see if you did this
int a=*p;
debug_var (a.....
that the str_for_num (NULL,vv) which is debug_var , would work no problem .
sooo , I don't know why string functions do not work with dereference , could it be because its a dereference to different types ?
no idea , but yeah
Compulsive compiler
|
|
|
Re: What's stopping you from actually learning programming?
[Re: Wjbender]
#452918
06/30/15 13:52
06/30/15 13:52
|
Joined: May 2009
Posts: 5,370 Caucasus
3run
Senior Expert
|
Senior Expert
Joined: May 2009
Posts: 5,370
Caucasus
|
sooo , I don't know why string functions do not work with dereference , could it be because its a dereference to different types ? yeah, I would like to know why too lite-c does auto-pointer-casting, it's fucked up doesn't it get turned off with pragmatic_pointer?
|
|
|
|