Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
M1 Oversampling
by 11honza11. 04/20/24 20:57
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Quad), 454 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 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: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
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 Offline
Serious User
AndrewAMD  Offline
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