Knowee
Questions
Features
Study Tools

Identify the incorrect syntax for a pointer to a structure:Assuming the structure: struct temp { int b; } *obj;

Question

Identify the incorrect syntax for a pointer to a structure:

Assuming the structure:

struct temp { int b; } *obj;
🧐 Not the exact question you are looking for?Go ask a question

Solution

The syntax you provided for declaring a pointer to a structure is correct. Here is how it works:

  1. struct temp is the declaration of the structure. This structure contains one member: int b.

  2. *obj is the declaration of a pointer to a structure of type temp. The asterisk (*) before obj indicates that obj is a pointer.

So, struct temp { int b; } *obj; is a correct syntax for declaring a pointer to a structure in C/C++.

However, if you want to see an incorrect syntax, here are a few examples:

  • struct temp { int b } *obj; - This is incorrect because it lacks a semicolon (;) at the end of the structure declaration.
  • struct temp { int b; } obj*; - This is incorrect because the asterisk (*) should be before obj, not after.
  • struct temp { int b; } *; - This is incorrect because it lacks the name of the pointer (in this case, obj).

This problem has been solved

Similar Questions

If a variable is a pointer to a structure, then which of the following operator is used to access data members of the structure through the pointer variable?

Which of the following cannot be a structure member?*1 pointA. FunctionB. ArrayC. StructureD. None of the above

Prior to using a pointer variable it should beQuestion 2Answera. Declaredb.None of thesec. Both declared and initalizedd. Initialized

Which of the following cannot be a structure member?Question 19Select one:Another structureFunctionArrayNone of the mentioned

Which keyword is used to declare an object of a class in C++?objectstructnewclass

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.