edited by
584 views
2 votes
2 votes

Consider the declaration below:

typedef char *Str_typed;
#define Str_defined char*
Str_typed s1, s2;
Str_defined s3, s4;


Which one of the following statements is correct?
I. $s1$, $s2$, $s3$ and $s4$ are character pointers
II. $s1$, $s2$, $s3$ and $s4$ are characters
III. $s1$, $s2$, $s3$ are character pointers while $s4$ is a character
IV. None of the above

edited by

2 Answers

1 votes
1 votes

answer is option 3.

typedef renames the data type of the variable . so str_typed will act as char pointer .(s1,s2 both of them are char pointers).

str_defined macro template will be replaced by its macro expansion during preprocessing .

str_defined will be replaced  by char*.

str_defined s3,s4; ===> char* s3,s4;

s3 is pointer whereas s4 is normal character variable. 

https://onlinegdb.com/rkmTwrG9G

edited by
0 votes
0 votes
Str_typed s1, s2;
Str_defined s3, s4;

that means s1 is of Str_typed

s2 is also Str_typed

hence s1 and s2 are pointer

while in #define 

char *s3 and char s4

so (C)

Related questions

3 votes
3 votes
1 answer
1
Storm_907 asked Apr 16, 2023
476 views
Please explain this question void main() { int a =300; char *ptr = (char*) &a ; ptr++; *ptr=2; printf("%d" , a); }
4 votes
4 votes
4 answers
3
Manoj Kumar Pandey asked May 22, 2019
834 views
https://gateoverflow.in/?qa=blob&qa_blobid=14433986388826671915int main() { int a = 10; int *b = &a; scanf("%d",b); printf("%d",a+50); }What will be the Output of the fol...