start string.h
This commit is contained in:
parent
3a3f6cc424
commit
c29bc36514
2 changed files with 72 additions and 15 deletions
20
05/main.c
20
05/main.c
|
@ -3,7 +3,7 @@
|
|||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
int compar(const void *a, const void *b) {
|
||||
int i = *(int *)a;
|
||||
|
@ -14,20 +14,10 @@ int compar(const void *a, const void *b) {
|
|||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
ldiv_t l = ldiv(1000000000007, 5937448);
|
||||
printf("%ld %ld\n",l.quot,l.rem);
|
||||
int nums[10] = {8,34,1086,3872,-123,5873,3843,1762,INT_MAX,INT_MIN};
|
||||
int i;
|
||||
for (i = 0; i < 10; ++i) nums[i] = abs(nums[i]);
|
||||
qsort(nums, 10, sizeof(int), compar);
|
||||
for (i = 0; i < 10; ++i) printf("%d ", nums[i]);
|
||||
printf("\n");
|
||||
int search = 34;
|
||||
int *p = bsearch(&search, nums, 10, sizeof(int), compar);
|
||||
if (p)
|
||||
printf("Found %d\n",*p);
|
||||
else
|
||||
printf("No match\n");
|
||||
char buf[36];
|
||||
memset(buf, 'a', sizeof buf);
|
||||
strncpy(buf, "hello, world!\n",36);
|
||||
printf("%d\n",strcmp(buf, "hello, world!\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue