string compare

Posted By: Grat

string compare - 06/24/20 06:27

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;
}
Posted By: Petra

Re: string compare - 06/24/20 15:55

In lite-C you must put a string size in the brackets, like this: char str1[100] = "Look HerE";
Posted By: AndrewAMD

Re: string compare - 06/24/20 18:02

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
© 2024 lite-C Forums