Quantcast
Channel: Initialize recursive struct type in C properly - Stack Overflow
Browsing latest articles
Browse All 3 View Live

Answer by David C. Rankin for Initialize recursive struct type in C properly

While Akira has a very good answer for you (I voted for it), I would caution you about typedeffing pointers. Why? As your projects grow, when you start hiding levels of indirection behind a typedef,...

View Article



Answer by Akira for Initialize recursive struct type in C properly

You can do it as follows:#include <stdio.h>typedef struct _date { char d[11], t[6], s[4]; // +1 to size for null-terminator ('\0') struct _date *next;} *date;int main() { struct _date a = {...

View Article

Initialize recursive struct type in C properly

I am new to C programming and I have the following struct:typedef struct _date { char d[10], t[5], s[3]; struct _date *next;} *date;How can I properly create an instance of this?My solution:date...

View Article
Browsing latest articles
Browse All 3 View Live




Latest Images