typedef int *ptr; ptr p1, p2;
In this P2 is Integer Pointer or Integer?
#include <stdio.h> typedef int *ptr; int main() { ptr p1, p2; *p1 = 5; *p2 = 5; printf("%d\n", *p1); printf("%d\n", *p2); return 0; }
Output
5 5
Which proves that both p1 and p2 are of type (int *) i.e. integer pointer...
typedef will be effected on both variable p1 as well on p2. In case of both will be pointer p1 as well as p2
#define int *ptr
then ptr p1, p2; will be int *p1,p2; here only p1 will be pointer only.
No P2 is an Interger Pointer not Integer.
For eg: int *p1,p2; Then p1 will be the integer Pointer but p2 is an Integer.
#define MY_STRUCT typedef struct{ ... ... } my_struct;
Above code is giving me error (MY_STRUCT) is not working as expected, Looks that some silly mistake, please point out as I have wasted many hours?
Sorry for hiding my identity?
In large product based companies LLD is written by senior team members and developers write the code. Does the senior team member decide what data type they should use in advance ? If yes then what things derives type of data for example. How they decide a variable should be declared as volatile ? and what would be advantage of having a variable volatile and what could be the problem if it is taken without the volatile ?
How can I wwap value two variables without using third variable or +/- operator?
In a large project . There is a lots of header files included one another and I do not know the header file in which MYINT is define.
How will I know that MYINT is
#define MYINT int OR typedef int MYINT