Skip to content

Instantly share code, notes, and snippets.

@Phitherek
Created March 22, 2012 11:50
Show Gist options
  • Save Phitherek/2157886 to your computer and use it in GitHub Desktop.
Save Phitherek/2157886 to your computer and use it in GitHub Desktop.
Program do sprawdzenia, jak zachowują się stringi (z wykładu Hawka).
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
char a[3];
char b[3];
char c[3];
char tek[4];
*a = "aaa";
*b = "aba";
*c = "abc";
printf("strcmp(a,b) = %d\n", strcmp(a,b));
printf("strcmp(b,c) = %d\n", strcmp(b,c));
printf("strcmp(a,c) = %d\n", strcmp(a,c));
printf("strcmp(b,a) = %d\n", strcmp(b,a));
printf("strcmp(c,b) = %d\n", strcmp(c,b));
printf("strcmp(c,a) = %d\n", strcmp(c,a));
tek[0] = 'a';
tek[1] = '\0';
tek[2] = 'c';
tek[3] = '\0';
printf("sizeof(\"abc\") = %d\n", sizeof("abc"));
printf("strlen(\"abc\") = %d\n", strlen("abc"));
printf("sizeof(tek) = %d\n", sizeof(tek));
printf("strlen(tek) = %d\n", strlen(tek));
return EXIT_SUCCESS;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment