Exercise: Typedef

Questions for: Typedef

typedef's have the advantage that they obey scope rules, that is they can be declared local to a function or a block whereas #define's always have a global effect.
A:
Yes
B:
No
C:
D:
Answer: A
No answer description is available. Let's discuss.
Are the properties of i, j and x, y in the following program same?
typedef unsigned long int uli;
uli i, j;
unsigned long int x, y;
A:
Yes
B:
No
C:
D:
Answer: A
No answer description is available. Let's discuss.
Is there any difference in the #define and typedef in the following code?
typedef char * string_t;
#define string_d char *;
string_t s1, s2;
string_d s3, s4;
A:
Yes
B:
No
C:
D:
Answer: A
In these declarations, s1, s2 and s3 are all treated as char*, but s4 is treated as a char, which is probably not the intention.
Is the following declaration acceptable?
typedef long no, *ptrtono;
no n;
ptrtono p;
A:
Yes
B:
NO
C:
D:
Answer: A
No answer description is available. Let's discuss.
Point out the error in the following code?
typedef struct
{
    int data;
    NODEPTR link;
}*NODEPTR;
A:
Error: in *NODEPTR
B:
Error: typedef cannot be used until it is defined
C:
No error
D:
None of above
Answer: B
No answer description is available. Let's discuss.
Ad Slot (Above Pagination)
Quiz