We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 783c46a commit a373122Copy full SHA for a373122
code/C/format-string.c
@@ -0,0 +1,14 @@
1
+#include <stdio.h>
2
+#include <string.h>
3
+#include <stdlib.h>
4
+
5
+int main (int argc, char **argv) {
6
+ char buf[10] = { '\0' };
7
+ int x = 1;
8
+ snprintf(buf, sizeof(buf), argv[1]);
9
+ buf[sizeof(buf)-1] = 0;
10
+ printf("Buffer size is: (%d) \nData input: %s \n", strlen(buf), buf);
11
+ printf("in hex: %#x\nMemory address for x: (%p) \n", x, &x);
12
+ strdup(argv[1]);
13
+ return 0;
14
+}
0 commit comments