Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (howardR, 7th_zorro), 893 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
inchar(NULL) is giving wrong values #454882
09/27/15 08:40
09/27/15 08:40
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline OP
Expert
alibaba  Offline OP
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
Why is inchar giving bad values? Changing literally anything in this code fixes it, like removing the wait, removing the parameter whatever.

Code:
#include <acknex.h>
#include <default.c>

STRING* testStr="abcd";

void input(STRING* str)
{
	while(1)
	{
		char lol=inchar(NULL);
		printf(lol);
		wait(1);
	}
}
void main()
{
	input(testStr);
}



EDIT: Also having lol as var and then casting as char gives bad values.

Last edited by alibaba; 09/27/15 08:40.

Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: inchar(NULL) is giving wrong values [Re: alibaba] #454886
09/27/15 09:41
09/27/15 09:41
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
You cant do "printf(lol);" because every char pointer/array has to be terminated using "0" called the string terminator.

Re: inchar(NULL) is giving wrong values [Re: Ch40zzC0d3r] #454887
09/27/15 10:02
09/27/15 10:02
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline
Expert
Kartoffel  Offline
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
^: also printf needs a specific syntax, consisting of a static format string, followed by as many vars as you want to display.

so it's printf("%c", lol); for a single char.

EDIT: oh, and try putting a wait(1); between the inchar and the printf.
I think I had to use something similar when I made a japanese kana input for someone.

Last edited by Kartoffel; 09/27/15 10:11.

POTATO-MAN saves the day! - Random
Re: inchar(NULL) is giving wrong values [Re: Kartoffel] #454890
09/27/15 11:55
09/27/15 11:55
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline OP
Expert
alibaba  Offline OP
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
Okay solved! Sorry I have completely forgotten to null-terminate the char >.<"

Thanks!


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1