Download benchmarks/Engineering/string/strcmp/solution.c from PV-SJTU/PV-Bench: direct link, hf CLI and curl.
- Browser
- Download file 309 Bytes
-
https://huggingface.co/datasets/PV-SJTU/PV-Bench/resolve/main/benchmarks/Engineering/string/strcmp/solution.c
- Command line
-
hf download hf://datasets/PV-SJTU/PV-Bench/benchmarks/Engineering/string/strcmp/solution.c
-
curl -L -o solution.c https://huggingface.co/datasets/PV-SJTU/PV-Bench/resolve/main/benchmarks/Engineering/string/strcmp/solution.c
309 Bytes
| int strcmp(char *s1, char *s2) | |
| { | |
| int i = 0; | |
| while (s1[i] != 0 && s1[i] == s2[i]) { | |
| i++; | |
| } | |
| return s1[i] - s2[i]; | |
| } | |
| int strncmp(char *s1, char *s2, int n) | |
| { | |
| int i = 0; | |
| while (i < n && s1[i] != 0 && s1[i] == s2[i]) { | |
| i++; | |
| } | |
| if (i == n) { | |
| return 0; | |
| } | |
| return s1[i] - s2[i]; | |
| } | |