User Tools

Site Tools


Programming Reference/Librarys

Question & Answer

Q&A is closed

    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;
  user@host:~$ ./memcmp 
  String:"Teststring" is greater as  String:"test"

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
c/string.h/memcmp.txt · Last modified: 2024/02/16 01:06 (external edit)

Impressum Datenschutz