Merge pull request #75 from azymohliad/master

Implement strstr() and strpbrk() from string.h
This commit is contained in:
Jeremy Soller
2018-03-14 21:22:59 -06:00
committed by GitHub
8 changed files with 69 additions and 4 deletions
+20
View File
@@ -0,0 +1,20 @@
#include <string.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
char* source = "The quick drawn fix jumps over the lazy bug";
// should be "The quick drawn fix jumps over the lazy bug"
char* res1 = strpbrk(source, "From The Very Beginning");
printf("%s\n", (res1) ? res1 : "NULL");
// should be "lazy bug"
char* res2 = strpbrk(source, "lzbg");
printf("%s\n", (res2) ? res2 : "NULL");
// should be "NULL"
char* res3 = strpbrk(source, "404");
printf("%s\n", (res3) ? res3 : "NULL");
return 0;
}
+18
View File
@@ -0,0 +1,18 @@
#include <string.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
// should be "rust"
char* res1 = strstr("In relibc we trust", "rust");
printf("%s\n", (res1) ? res1 : "NULL");
// should be "libc we trust"
char* res2 = strstr("In relibc we trust", "libc");
printf("%s\n", (res2) ? res2 : "NULL");
// should be "NULL"
char* res3 = strstr("In relibc we trust", "bugs");
printf("%s\n", (res3) ? res3 : "NULL");
return 0;
}