Deklaracja edytuj

int strcmp(const char *s1, const char *s2)

Plik nagłówkowy edytuj

string.h

Opis działania edytuj

Funkcja strcmp porównuje napisy s1 i s2.

Zwracane wartości edytuj

Funkcja zwraca wartość zero, gdy s1 jest takie same jak s2, mniejszą od zera gdy s1 < s2 oraz większą od zera gdy s1 > s2.

Przykład edytuj

#include <stdio.h>
#include <string.h>

int main (void)
{
    char s1[] = "Wikibooks";
    char s2[] = "Wikibooks";
   
    if (strcmp(s1, s2) == 0)
        printf("Łańcuchy s1 i s2 są takie same");
    else
        printf("Łańcuchy s1 i s2 nie są takie same");

    // program wyświetli: Łańcuchy s1 i s2 są takie same

    return 0;
}