Yeah someone tell me how to define a new data type!!!
This is a discussion on Data Types Dammit! within the C Programming forums, part of the General Programming Boards category; Yeah someone tell me how to define a new data type!!!...
Yeah someone tell me how to define a new data type!!!
The only new types you can create are structures (and less frequently unions).
Like so...
And you would create a variable of that type byCode:struct foo { char name[30]; int age; };
Now you can hide some of the detail by using a typedef, but that doesn't create anything new, it just creates a new way to refer to something which already exists.Code:struct foo student; struct foo all_students[100];
The two variables above can be expressed in exactly the same way by doing this...Code:typedef struct foo foo_st;
Code:foo_st student; foo_st all_students[100];
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.