Banashree Patra
Banashree Patra
Branch Unspecified
23 Apr 2012

Data structure: Identify the correct option

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
nareshkumar6539

nareshkumar6539

Branch Unspecified
23 Apr 2012
if first line is like below
typedef char *Str_typed;
then answer is none of the above
if first line is like below
typedef char* Str_typed;
then answer is I
Banashree Patra

Banashree Patra

Branch Unspecified
23 Apr 2012
nareshkumar6539
if first line is like below
typedef char *Str_typed;
then answer is none of the above
if first line is like below
typedef char* Str_typed;
then answer is I
That means in the second line Str_typed is a character pointer.
Can you tell me what does char* means in your 5th line.
nareshkumar6539

nareshkumar6539

Branch Unspecified
23 Apr 2012
char * means character pointer varible
Banashree Patra

Banashree Patra

Branch Unspecified
23 Apr 2012
nareshkumar6539
char * means character pointer varible
yes but what does char* means?
nareshkumar6539

nareshkumar6539

Branch Unspecified
23 Apr 2012
Banashree Patra
yes but what does char* means?
that is my typing mistake i need to be give space there
Banashree Patra

Banashree Patra

Branch Unspecified
23 Apr 2012
Hey naresh i am not getting your answer.Can you please explain it elaborately.
nareshkumar6539

nareshkumar6539

Branch Unspecified
23 Apr 2012
if there is no space between * and Str_typed then below is answer
typedef can be used for renaming the predefined keywords.
typedef char *Str_typed;
this means for declaring character varibles instead of using char we can use *Str_typed
in the code Str_typed s1, s2
so in above code Str_typed is undefined it will give error.
if there is space between * and Str_typed then below is answer
typedef char * Str_typed;
if we have space between * Str_typed then the above meaning is for declaring character pointer we can use Str_typed . In this case first option is correct.

Share this content on your social channels -

Only logged in users can reply.