{"id":52,"date":"2023-03-16T02:47:08","date_gmt":"2023-03-16T02:47:08","guid":{"rendered":"https:\/\/www.brigadiercomputers.com\/index.php\/2023\/03\/16\/a-program-that-has-a-structure-that-stores-rpg-d6-stats\/"},"modified":"2023-03-16T02:47:08","modified_gmt":"2023-03-16T02:47:08","slug":"a-program-that-has-a-structure-that-stores-rpg-d6-stats","status":"publish","type":"post","link":"https:\/\/www.brigadiercomputers.com\/index.php\/2023\/03\/16\/a-program-that-has-a-structure-that-stores-rpg-d6-stats\/","title":{"rendered":"A program that has a structure that stores RPG D6 stats"},"content":{"rendered":"<p>Here&#8217;s an example program in C that defines a structure to store RPG d6 stats:<\/p>\n<div class=\"bg-black rounded-md mb-4\">\n<div class=\"flex items-center relative text-gray-200 bg-gray-800 px-4 py-2 text-xs font-sans justify-between rounded-t-md\">\n<!--more--><br \/>\n<code class=\"!whitespace-pre hljs language-c\"><span class=\"hljs-meta\">#<span class=\"hljs-keyword\">include<\/span> <span class=\"hljs-string\">&lt;stdio.h&gt;<\/span><\/span><\/p>\n<p><span class=\"hljs-class\"><span class=\"hljs-keyword\">struct<\/span> <span class=\"hljs-title\">RPGStats<\/span> {<\/span><br \/>\n    <span class=\"hljs-type\">int<\/span> strength;<br \/>\n    <span class=\"hljs-type\">int<\/span> dexterity;<br \/>\n    <span class=\"hljs-type\">int<\/span> constitution;<br \/>\n    <span class=\"hljs-type\">int<\/span> intelligence;<br \/>\n    <span class=\"hljs-type\">int<\/span> wisdom;<br \/>\n    <span class=\"hljs-type\">int<\/span> charisma;<br \/>\n};<\/p>\n<p><span class=\"hljs-type\">int<\/span> <span class=\"hljs-title function_\">main<\/span><span class=\"hljs-params\">()<\/span> {<br \/>\n    <span class=\"hljs-class\"><span class=\"hljs-keyword\">struct<\/span> <span class=\"hljs-title\">RPGStats<\/span> <span class=\"hljs-title\">stats<\/span>;<\/span><br \/>\n    stats.strength = <span class=\"hljs-number\">3<\/span>;<br \/>\n    stats.dexterity = <span class=\"hljs-number\">4<\/span>;<br \/>\n    stats.constitution = <span class=\"hljs-number\">2<\/span>;<br \/>\n    stats.intelligence = <span class=\"hljs-number\">5<\/span>;<br \/>\n    stats.wisdom = <span class=\"hljs-number\">1<\/span>;<br \/>\n    stats.charisma = <span class=\"hljs-number\">6<\/span>;<\/p>\n<p>    <span class=\"hljs-built_in\">printf<\/span>(<span class=\"hljs-string\">\"Strength: %d\\n\"<\/span>, stats.strength);<br \/>\n    <span class=\"hljs-built_in\">printf<\/span>(<span class=\"hljs-string\">\"Dexterity: %d\\n\"<\/span>, stats.dexterity);<br \/>\n    <span class=\"hljs-built_in\">printf<\/span>(<span class=\"hljs-string\">\"Constitution: %d\\n\"<\/span>, stats.constitution);<br \/>\n    <span class=\"hljs-built_in\">printf<\/span>(<span class=\"hljs-string\">\"Intelligence: %d\\n\"<\/span>, stats.intelligence);<br \/>\n    <span class=\"hljs-built_in\">printf<\/span>(<span class=\"hljs-string\">\"Wisdom: %d\\n\"<\/span>, stats.wisdom);<br \/>\n    <span class=\"hljs-built_in\">printf<\/span>(<span class=\"hljs-string\">\"Charisma: %d\\n\"<\/span>, stats.charisma);<\/p>\n<p>    <span class=\"hljs-keyword\">return<\/span> <span class=\"hljs-number\">0<\/span>;<br \/>\n}<br \/>\n<\/code><\/div>\n<\/div>\n<p>In this example, we define a structure called <code>RPGStats<\/code> that has six integer fields to store d6 stats for a character. In the <code>main()<\/code> function, we create an instance of the <code>RPGStats<\/code> structure called <code>stats<\/code> and initialize its fields with some sample values. Then, we print out each of the field values using <code>printf()<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s an example program in C that defines a structure to store RPG d6 stats:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"class_list":["post-52","post","type-post","status-publish","format-standard","hentry","category-development"],"_links":{"self":[{"href":"https:\/\/www.brigadiercomputers.com\/index.php\/wp-json\/wp\/v2\/posts\/52","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.brigadiercomputers.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.brigadiercomputers.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.brigadiercomputers.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.brigadiercomputers.com\/index.php\/wp-json\/wp\/v2\/comments?post=52"}],"version-history":[{"count":0,"href":"https:\/\/www.brigadiercomputers.com\/index.php\/wp-json\/wp\/v2\/posts\/52\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.brigadiercomputers.com\/index.php\/wp-json\/wp\/v2\/media?parent=52"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.brigadiercomputers.com\/index.php\/wp-json\/wp\/v2\/categories?post=52"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.brigadiercomputers.com\/index.php\/wp-json\/wp\/v2\/tags?post=52"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}