Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
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
1 registered members (blaurock), 750 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
string compare #480657
06/24/20 06:27
06/24/20 06:27
Joined: May 2015
Posts: 390
Czech Republic
G
Grat Offline OP
Senior Member
Grat  Offline OP
Senior Member
G

Joined: May 2015
Posts: 390
Czech Republic
Hi,

how to in Zorro make this:
Code
int main()
{
	char str1[] = "Look HerE";
	char str2[] = "Look Here";

	printf("%d\n", strncmp(str1, str2, 8));
	printf("%d\n", strncmp(str1, str2, 9));

	return 0;
}

Re: string compare [Re: Grat] #480664
06/24/20 15:55
06/24/20 15:55
Joined: Apr 2008
Posts: 586
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 586
Austria
In lite-C you must put a string size in the brackets, like this: char str1[100] = "Look HerE";

Re: string compare [Re: Grat] #480666
06/24/20 18:02
06/24/20 18:02
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Use Windows' standard library functions, like this:
Code
int __cdecl strncmp(const char *string1, const char *string2, unsigned int count);
API(strncmp,msvcrt)

void main(void){
	char* str1 = "Look HerE";
	char* str2 = "Look Here";
	printf("\n%d", strncmp(str1, str2, 8));
	printf("\n%d", strncmp(str1, str2, 9));
}

/* output:
0
-32
*/

https://docs.microsoft.com/en-us/cp...p-wcsncmp-mbsncmp-mbsncmp-l?view=vs-2019
https://zorro-project.com/manual/en/litec_api.htm


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1