Rev 3688 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3688 | Rev 13928 | ||
---|---|---|---|
Line 4... | Line 4... | ||
4 | * This is all amateur scriblings... So no copyrights. * |
4 | * This is all amateur scriblings... So no copyrights. * |
5 | * This source code file, and compiled objects derived from it, * |
5 | * This source code file, and compiled objects derived from it, * |
6 | * can be used and distributed without restriction, including for commercial use * |
6 | * can be used and distributed without restriction, including for commercial use * |
7 | * No warrenty whatoever * |
7 | * No warrenty whatoever * |
8 | ********************************************************************************* |
8 | ********************************************************************************* |
- | 9 | ||
- | 10 | 7/5/2019 use strlcpy, strlcat - size-bounded string copying and concatenation |
|
9 | */ |
11 | */ |
10 | 12 | ||
11 | #include <stdio.h> |
13 | #include <stdio.h> |
12 | #include <stdlib.h> |
14 | #include <stdlib.h> |
13 | #include <string.h> |
15 | #include <string.h> |
Line 34... | Line 36... | ||
34 | fprintf(stdout,"error! size of word is bigger than %d\n",MAX_SIZE); |
36 | fprintf(stdout,"error! size of word is bigger than %d\n",MAX_SIZE); |
35 | exit(0); |
37 | exit(0); |
36 | } |
38 | } |
37 | else |
39 | else |
38 | { |
40 | { |
39 |
|
41 | strlcpy( word, ptr, sizeof(word) ) ; |
40 | total = 0; |
42 | total = 0; |
41 | for( i = 0;i < length ;i++ ){ |
43 | for( i = 0;i < length ;i++ ){ |
42 | total = total + word[i]; |
44 | total = total + word[i]; |
43 | } |
45 | } |
44 | } |
46 | } |