User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







c:string.h:memcmp
    int memcmp(const void *str1, const void *str2, size_t n);

check the size of a string and string2 and return a value

  less 0 	string1 lesser than string2
  equal 0 	string1 equal string2
  greater 0 	string1 greater than string2
#include <stdio.h> /* including standard library */
//#include <windows.h> /* uncomment this for Windows */
 
#include <string.h>
#define MAX 42
int main ( void )
{
  char string1[MAX]="Teststring";
  char string2[MAX]="test";
  int i;
  i = memcmp ( string1, string2, MAX  );
  if (i < 0) {
        printf("String:\"%s\" is greater as  String:\"%s\"\n", string1, string2); /* is greater */
      } 
  return 0;
}
  output:
  user@host:~$ ./memcmp 
  String:"Teststring" is greater as  String:"test"
advertising
c/string.h/memcmp.txt · Last modified: 2013/01/22 22:02 (external edit)

Impressum Datenschutz