{"id":780,"date":"2010-03-05T09:58:15","date_gmt":"2010-03-05T09:58:15","guid":{"rendered":"http:\/\/www.codingfriends.com\/?p=780"},"modified":"2010-03-05T09:58:15","modified_gmt":"2010-03-05T09:58:15","slug":"struct-initialization-values","status":"publish","type":"post","link":"https:\/\/www.codingfriends.com\/index.php\/2010\/03\/05\/struct-initialization-values\/","title":{"rendered":"struct &#8211; initialization values"},"content":{"rendered":"<p>When you define a new <a href=\"http:\/\/en.wikipedia.org\/wiki\/Struct_%28C_programming_language%29\">struct<\/a>(ure) and initialize it you can use the {} to define the internals of the values within for example<\/p>\n<pre lang=\"cpp\">\r\ntypedef struct\r\n{\r\n    int coding;\r\n    int friends;\r\n} newType;\r\n\r\nnewType nT = { 10, 20};\r\n<\/pre>\n<p>so coding = 10 and friends = 20<\/p>\n<p>But if you try and over initialize the values that are not present, e.g. <\/p>\n<pre lang=\"cpp\">\r\nnewType nT = { 10, 20, 30 }; \/\/ there is not place to put the 30\r\n<\/pre>\n<p>then the compiler will compile with<\/p>\n<pre lang=\"bash\">\nerror: too many initializers for <\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you define a new struct(ure) and initialize it you can use the {} to define the internals of the values within for example typedef struct { int coding; int friends; } newType; newType nT = { 10, 20}; so coding = 10 and friends = 20 But if you try and over initialize the &hellip; <a href=\"https:\/\/www.codingfriends.com\/index.php\/2010\/03\/05\/struct-initialization-values\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">struct &#8211; initialization values<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[132,104],"class_list":["post-780","post","type-post","status-publish","format-standard","hentry","category-c_and_cpp","tag-initialization","tag-struct"],"_links":{"self":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/780","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/comments?post=780"}],"version-history":[{"count":1,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/780\/revisions"}],"predecessor-version":[{"id":781,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/780\/revisions\/781"}],"wp:attachment":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/media?parent=780"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/categories?post=780"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/tags?post=780"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}