One97 Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
3
of 3 vote

To summarize
sizeof(void) is not allowed in c++
1 is returned in c

- ccyy January 23, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I think it is machine and compiler dependent. The answer may vary here.

- systemguru February 05, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

4

- Vipul December 18, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

max@kearny ~/tmp $ cat test.cc
#include <iostream>

using namespace std;

int main() {
cout << sizeof(void) << endl;
return 0;
}
max@kearny ~/tmp $ g++ -o test test.cc
test.cc: In function ‘int main()’:
test.cc:6: error: invalid application of ‘sizeof’ to a void type
max@kearny ~/tmp $

- Anonymous December 19, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

sizeof() is not defined for void type

- Anonymous December 19, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

When I compiled it on GCC, I got it sizeof(void) as 1 ...

- Vikas Upendra December 21, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Even I got 1 as ouput.

- Jit December 21, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

even u? oh shi, that means it must have 1 in size then

- Anonymous December 22, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

sizeof(void) is 'Illigal sizeof operand' on Windows

And, Dec 19, 2010 comments of Annonyms are correct on Unix

- Maninder December 26, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

ERROR:not an allowed type

on borland c compiler

- sandy880 January 18, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think there is no point of having sizeof defined for void.

- Anonymous February 06, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

main()
{
printf("%d",sizeof(void));
}
o/p is 1.

- varun April 27, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void means "type" information for any variable is un-known. and result of calling sizeof() operator for unknown types is un-defined. No matter what compiler returns ( error or 1 ) it should return in error. ( hopefully compile time).

- BhupinderSingh March 01, 2014 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More