Is there a d analog of strncmp?

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Aug 21 17:14:31 PDT 2016


int strncmp(string a, string b, int n) {
	if(a.length > n)
		a = a[0 .. n];
	if(b.length > n)
		b = b[0 .. n];
	import std.algorithm.comparison : cmp;
	return cmp(a, b);
}


More information about the Digitalmars-d-learn mailing list