[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
CMemcmp

(C) memcmp

C function for comparing two buffers (of type char*).

  1. include <stdio.h>
  2. include <string.h>
int main () { char str1[] = "Sentence 1"; char str2[] = "Sentence 2"; int length1 = strlen(str1); int length2 = strlen(str2); int comparison = memcmp (str1, str2, max(length1,length2)); if (comparison>0) { sprintf("str1 is greater than str2"); } else if (comparison<0) { sprintf("str1 is less than str2"); } else { sprintf("str1 is equal to str2"); } return 0; }


'memcmp' links



last edited (November 8, 2006) by bilderbikkel, Number of views: 1066, Current Rev: 1

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.