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

Replies

  • nareshkumar6539
    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
  • Banashree Patra
    Banashree Patra
    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
    char * means character pointer varible
  • Banashree Patra
    Banashree Patra
    nareshkumar6539
    char * means character pointer varible
    yes but what does char* means?
  • nareshkumar6539
    nareshkumar6539
    Banashree Patra
    yes but what does char* means?
    that is my typing mistake i need to be give space there
  • Banashree Patra
    Banashree Patra
    Hey naresh i am not getting your answer.Can you please explain it elaborately.
  • nareshkumar6539
    nareshkumar6539
    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.

You are reading an archived discussion.

Related Posts

Name: AMITA ACHARYA *Engineering Trade: MCA Location: MUMBAI *Occupation: (Student) Work Experience: (if applicable) *Hobbies & Interests: LISTENING MUSIC *Aim in life: a SUCCESSFUL PERSON *I joined CrazyEngineers because: MANY...
Consider the following program fragment: 1. i = 1; sum=0; 2. while (i <= n) do begin 3. sum = sum + a; 4. i = i + 1; end...
A logic circuit has three Boolean inputs X,Y and Z. Its output is F(X,Y,Z) such that: F(X,Y,Z) = 1 if aX + bY +cZ > d = 0 otherwise. a,b,c,d...
Write an efficient algorithm to find the first non-repeated character in a string defined over the English alphabet set [a-z, A-Z]. For example, the first non-repeated character in teeter is...
Imagine a cubic array made up of an n*n*n arrangement of unit cubes: the cubic array is n cubes wide, n cubes high and n cubes deep. A special case...