C Programming - Typedef - Discussion
Discussion Forum : Typedef - Find Output of Program (Q.No. 5)
5.
What is the output of the program?
typedef struct data;
{
int x;
sdata *b;
}sdata;
Answer: Option
Explanation:
since the type 'sdata' is not known at the point of declaring the structure
Discussion:
10 comments Page 1 of 1.
Dyslexic ivern said:
2 years ago
> Error: Declaration missing ';'.
This test is not missing ';' it is too much of ';'.
This test is not missing ';' it is too much of ';'.
Arie1 said:
9 years ago
In visual C++ give those:
Warning C4091: 'typedef ': ignored on left of 'main::data' when no variable is declared.
Error C2065: 'sdata': undeclared identifier.
Error C2065: 'b': undeclared identifier.
Error C2065: 'sdata': undeclared identifier.
Warning C4091: 'typedef ': ignored on left of 'main::data' when no variable is declared.
Error C2065: 'sdata': undeclared identifier.
Error C2065: 'b': undeclared identifier.
Error C2065: 'sdata': undeclared identifier.
Vijay jeyakumar said:
9 years ago
I can't understand still. Please clarify me.
Ronja said:
9 years ago
When I tried the error will be like this:
6:16: warning: 'typedef' was ignored in this declaration
7:1: error: expected unqualified-id before '{' token
10:2: error: 'sdata' does not name a type
How to rectify this?
6:16: warning: 'typedef' was ignored in this declaration
7:1: error: expected unqualified-id before '{' token
10:2: error: 'sdata' does not name a type
How to rectify this?
Gokila said:
1 decade ago
Typedef is a keyword. The purpose of typedef is to assign alternative names to existing types, most often confusing, or likely to vary from one implementation to another.
Supraja said:
1 decade ago
What is the purpose of typedef?
Om Prakash said:
1 decade ago
Error will be:
Undefined symbol sdata.
Because the block will be treated differently and sdata differently.
Undefined symbol sdata.
Because the block will be treated differently and sdata differently.
Peter Arnt said:
1 decade ago
I maintain that the initial error is in the first line.
typedef struct data; <---<<<
You have a semicolon here which yields an incomplete typedef statement.
This causes the '{' on the next line to trigger more errors.
The fact that 'sdata' is not defined is the least of your troubles.
Whoever created this test should be re-tested themselves.
typedef struct data; <---<<<
You have a semicolon here which yields an incomplete typedef statement.
This causes the '{' on the next line to trigger more errors.
The fact that 'sdata' is not defined is the least of your troubles.
Whoever created this test should be re-tested themselves.
(4)
Jim Rucker said:
1 decade ago
From Microsoft's C compiler:
'{' : missing function header (old-style formal list?)
I don't know what compiler would see a random { in your global space without a compile error.
'{' : missing function header (old-style formal list?)
I don't know what compiler would see a random { in your global space without a compile error.
King said:
1 decade ago
Error will Be like this
" Undefined symbol sdata"
" Undefined symbol sdata"
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers