Data structure: Identify the correct option

Banashree Patra
@banashree-patra-m0OJwR โ€ข Oct 22, 2024

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

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • nareshkumar6539

    @nareshkumar6539-BKuVbx • Apr 23, 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-m0OJwR • Apr 23, 2012

    nareshkumar6539if 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-BKuVbx • Apr 23, 2012

    char * means character pointer varible

  • Banashree Patra

    @banashree-patra-m0OJwR • Apr 23, 2012

    nareshkumar6539char * means character pointer varible

    yes but what does char* means?

  • nareshkumar6539

    @nareshkumar6539-BKuVbx • Apr 23, 2012

    Banashree Patrayes but what does char* means?

    that is my typing mistake i need to be give space there

  • Banashree Patra

    @banashree-patra-m0OJwR • Apr 23, 2012

    Hey naresh i am not getting your answer.Can you please explain it elaborately.

  • nareshkumar6539

    @nareshkumar6539-BKuVbx • Apr 23, 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.