NetApp Interview Question for Software Engineer / Developers


Country: India




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

In printf of *c when you try to dereference an uninitialized pointer, you are most likely to access some address which is not part of your allocated stack and you will get Seg Fault.

For &c you are right. It can get allocated any where on the stack where compiler finds some space for it.

- Anonymous October 04, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

no,... pointer c will be pointing to some garbage location in the memory if u haven't initialized it ....so at every run for *c and c there may be different values... in the case when your pointer is containing null address and u tries to dereference it ,then it will produce segmentaion fault.

- Get_RiGhT August 25, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

>>For &c you are right.
Not really.

&C should print the same location. However, if the OS is doing stack randomization, yes, you will see different values. So this depends on each OS implementation.

- Anonymous February 25, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

l

- Anonymous February 25, 2015 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

printf("\n%d", *c) - Mostly results in segmentation fault, i.e., you are trying to access memory location which is not allowed . Mostly the program terminates here but in case the pointer variable has some valid address then program prints that valid data pointed by c and proceed to execute next line of code.
printf("\n%d", c) - prints the content of the pointer variable; because the variable is not intialized, we will find a junk value
printf("\n%d", &c) - prints the address of the pointer varible 'c'

- Anonymous August 02, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

exit from this program ,
run two three program with infinite loop in that .
start this program again .

- Rakesh Kushwaha October 05, 2011 | 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