Rev 13928 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 13928 | Rev 13932 | ||
---|---|---|---|
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 |
- | |
11 | */ |
9 | */ |
12 | 10 | ||
13 | #include <stdio.h> |
11 | #include <stdio.h> |
14 | #include <stdlib.h> |
12 | #include <stdlib.h> |
15 | #include <string.h> |
13 | #include <string.h> |
Line 36... | Line 34... | ||
36 | fprintf(stdout,"error! size of word is bigger than %d\n",MAX_SIZE); |
34 | fprintf(stdout,"error! size of word is bigger than %d\n",MAX_SIZE); |
37 | exit(0); |
35 | exit(0); |
38 | } |
36 | } |
39 | else |
37 | else |
40 | { |
38 | { |
41 |
|
39 | strncpy( word, ptr, length ) ; |
42 | total = 0; |
40 | total = 0; |
43 | for( i = 0;i < length ;i++ ){ |
41 | for( i = 0;i < length ;i++ ){ |
44 | total = total + word[i]; |
42 | total = total + word[i]; |
45 | } |
43 | } |
46 | } |
44 | } |
Line 48... | Line 46... | ||
48 | ptr = (char *) strtok(NULL, ","); |
46 | ptr = (char *) strtok(NULL, ","); |
49 | } |
47 | } |
50 | fprintf(stdout,"\n"); |
48 | fprintf(stdout,"\n"); |
51 | return 0 ; |
49 | return 0 ; |
52 | } |
50 | } |
- | 51 |