Skip to content
Snippets Groups Projects
Commit cba611a0 authored by Pierre Kunzli's avatar Pierre Kunzli
Browse files

ajout demo str

parent 5e1d6b42
Branches
No related tags found
No related merge requests found
#include <stdio.h>
#include <string.h>
int main(int argc, char** argv){
// strlen example
printf("'%s' length : %zu\n", argv[1], strlen(argv[1]));
printf("'%s' length : %zu\n", argv[2], strlen(argv[2]));
// strcpy example
int l1 = strlen(argv[1]);
char copy[l1+1];
strcpy(copy, argv[1]);
// strcmp example
if(strcmp(argv[1], copy) == 0){
printf("'%s' == '%s'\n", argv[1], copy);
} else {
printf("'%s' != '%s'\n", argv[1], copy);
}
if(strcmp(argv[1], argv[2]) == 0){
printf("'%s' == '%s'\n", argv[1], argv[2]);
} else {
printf("'%s' != '%s'\n", argv[1], argv[2]);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment