|
Post by aurel on Apr 10, 2023 15:34:37 GMT -6
here is explanation from one site : note i am stupid for C ...heh The C language contains the typedef keyword to allow users to provide alternative names for the primitive (e.g., int) and user-defined (e.g struct) data types. Remember, this keyword adds a new name for some existing data type but does not create a new type. 1. Variable declaration without using typedef:#include<stdio.h> struct Point{ int x; int y; }; int main() { struct Point p1; p1.x = 1; p1.y = 3; printf("%d \n", p1.x); printf("%d \n", p1.y); return 0; } 2. Using the typedef keyword:
#include<stdio.h> struct Point{ int x; int y; }; typedef struct Point Point; int main() { Point p1; p1.x = 1; p1.y = 3; printf("%d \n", p1.x); printf("%d \n", p1.y); return 0; }
|
|
|
Post by tbird on Apr 10, 2023 15:48:55 GMT -6
aurel I'm pretty sure rosy was referring to my Subject title, not your post. I put Structs OR Types for naming convention only, ex. Purebasic uses the term Structures, I was just saying I would like that added named either of those, and as n00b already knew what I meant, rosy your point is pretty pedantic and not really relevant.
|
|
|
Post by rosy on Apr 11, 2023 3:39:05 GMT -6
You wrote that a type is a structure. I showed an example of a type (and a defined one) that is not a struct.
|
|
|
Post by n00b on Apr 11, 2023 7:00:19 GMT -6
You wrote that a type is a structure. I showed an example of a type (and a defined one) that is not a struct. Go look at Freebasic's documentation. tbird was referring to that. Type and structure are the same thing. If you are so upset about him using the word OR, you should just start a new thread about proper grammar.
|
|
|
Post by rosy on Apr 11, 2023 7:12:20 GMT -6
I'm just pointing out the confusion of terms. One thing is a type, another is a structure, and another is defining types. Just because FreeBasic uses the word "type" to define structures doesn't mean they're the same thing... And this use of the word OR was doubly confusing.
|
|
|
Post by aurel on Apr 11, 2023 23:29:55 GMT -6
Type and structure are the same thing
exactly ..it is same
|
|
|
Post by rosy on Apr 12, 2023 3:54:04 GMT -6
I give examples, I explain, and you go on with your...
|
|
|
Post by aurel on Apr 12, 2023 6:51:10 GMT -6
you give example?
where what ?? ..only example i saw here was tBird post
|
|
|
Post by aurel on Apr 12, 2023 7:13:50 GMT -6
here is simple example what it is and image talks more than 1000 words
|
|
|
Post by rosy on Apr 12, 2023 7:52:13 GMT -6
You even referred to this example. If you can't remember what you're doing and what you're talking about, it's a waste of my time...
|
|
|
Post by aurel on Apr 12, 2023 11:20:15 GMT -6
So now i can't remember ..nice ahhh nothing new yes i refer that you point in wrong direction talking about "sinonims" and do you look into my screenshot ... my question is how often you use types / structures / unions in your programs ? ahhh wasting time ..ouch such a BIG word
|
|
|
Post by rosy on Apr 12, 2023 12:52:59 GMT -6
I use them in almost every program. What does it have to do with it ?
|
|
|
Post by johnno56 on Apr 12, 2023 13:09:00 GMT -6
I too think that adding "type" to RC is a good idea. I enjoy a good discussion as much as the next guy, but please be careful with the discussion, so as not to reduce it to an argument. The original request was for "structs or type" (context infers the same). If stable enough, there maybe something added, by the time of version 3.22 release.
|
|
|
Post by aurel on Apr 12, 2023 23:14:01 GMT -6
I use them in almost every program
sure .. structures aka types aka UDT ..aka ...ha ha ha h
OMG...OMG...OMG
ahh..to much for my tiny brain...
|
|
|
Post by eyfenna on Aug 31, 2023 4:13:10 GMT -6
Nothing novel in this posting just perhaps it is of some use to get closer to an easy explanation for structs or types:
Rcbasic currently revolves around arrays, and structs or types are in sort of a way templates for "fixed sized associative arrays with varying element types" with which other variables can be formatted. Basically they are similar to associative arrays in power shell just that they have a drafting time or place, a stamping time or place, a setting and a usage time or place in code:
[example c]
drafting place struct SomeStruct{
int a;
int b;
}
stamping place
int main(){
struct SomeStruct thisIsLaterUsedInCode;
setting place thisIsLaterUsedInCode.a = 123; thisIsLaterUsedInCode.b = 12;
usage place
printf("My number a is %d\n", thisIsLaterUsedInCode.a);
printf("My number b is %d\n", thisIsLaterUsedInCode.b);
}
|
|