Initial commit
This commit is contained in:
21
kapitel6/cmp-strings.c
Normal file
21
kapitel6/cmp-strings.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char a[] = "Kalle";
|
||||
char b[] = "Lisa";
|
||||
|
||||
/* Skriver ut adressen till "Hej" */
|
||||
printf("%lu\n", (long unsigned int)"Hej");
|
||||
|
||||
/* Jämför strängar */
|
||||
if(strcmp(a, b) == 0)
|
||||
printf("%s och %s är detsamma\n", a, b);
|
||||
else if(strcmp(a, "Kalle") == 0)
|
||||
printf("%s = Kalle\n", a);
|
||||
else
|
||||
printf("Ingen match\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user