aboutsummaryrefslogtreecommitdiffstats
path: root/structest.c
diff options
context:
space:
mode:
Diffstat (limited to 'structest.c')
-rw-r--r--structest.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/structest.c b/structest.c
new file mode 100644
index 0000000..28888e5
--- /dev/null
+++ b/structest.c
@@ -0,0 +1,19 @@
+#include <stdio.h>
+#include <string.h>
+
+struct test {
+ char *string;
+ int length;
+};
+
+int main(int argc, char **argv)
+{
+ struct test t = {"Testing.", strlen("Testing.")};
+
+ char strbuf[256];
+
+ strncpy(strbuf, t.string, t.length + 1);
+ printf("%s\n", strbuf);
+
+ return 0;
+}