We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d660f1a commit 2f66be2Copy full SHA for 2f66be2
tests/regression/03-practical/27-charptr_null.c
@@ -0,0 +1,33 @@
1
+#include <string.h>
2
+#include <assert.h>
3
+#include <stdlib.h>
4
+#include <stdio.h>
5
+
6
+struct options
7
+{
8
+ char *ip_range;
9
+};
10
11
+struct options o;
12
13
+int get_ip_range(int *iprange)
14
15
+ char *r = iprange;
16
17
+ while (*r++)
18
+ {
19
+ *r = '\0';
20
+ assert(1);
21
+ }
22
23
+ return (0);
24
+}
25
26
+int main()
27
28
+ char *optarg = "was from unistd.h";
29
+ o.ip_range = malloc((strlen(optarg) + 1) * sizeof(char));
30
+ strncpy(o.ip_range, optarg, strlen(optarg));
31
+ o.ip_range[strlen(optarg)] = '\0';
32
+ get_ip_range(o.ip_range);
33
0 commit comments