Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 600 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 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 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