4. In the following code, the first printf() reached produces the output 14, but the second...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
4. In the following code, the first printf() reached produces the output “14,” but the second printf() can cause a bus error or a segmentation fault. Why? main () { int *p; funct (p); printf("%d\n", *p); } funct(int *p2) { p2=(int *) malloc (4); *p2=14; printf("%d\n", *p2); } 4. In the following code, the first printf() reached produces the output “14,” but the second printf() can cause a bus error or a segmentation fault. Why? main () { int *p; funct (p); printf("%d\n", *p); } funct(int *p2) { p2=(int *) malloc (4); *p2=14; printf("%d\n", *p2); }
Expert Answer:
Answer rating: 100% (QA)
The code snippet you provided is an example of improper use of pointers in the C programming language which can lead to undefined behavior including b... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
The site http://virtualpiano.net features an online player piano. If you click on the Key Assist menu just above the piano keyboard, and then Keyboard Keys, you will see that each key is labelled...
-
The Sooner Equipment Company has total assets of $100 million. Of this total, $40 million was financed with common equity and $60 million with debt (both long- and short-term). Its average accounts...
-
Rees Distributors uses the periodic inventory system. Rees reported these amounts at May 31, 2017: Inventory, May 31, 2016........................................... $29,000 Inventory, May 31,...
-
Part Three: Tax Position Advising: Summarize the results of the tax return in a memo and provide advice to the client explaining how they can avoid having a balance due for future tax returns. 1....
-
At constant temperature and pressure, the free energy for a chemically reacting system at equilibrium is (a) Minimum (b) Maximum (c) Can not be predicted (d) None of these.
-
Jen Corporation became a subsidiary of Laura Corporation on July 1, 2011, when Laura paid $1,980,000 cash for 90 percent of Jen's outstanding common stock. The price paid by Laura reflected the fact...
-
The shopping cart and its contents weigh 90 pounds, with the center of mass at G. Find the maximum force F that can be applied without the rear wheels at A lifting from the floor. What is the...
-
Determine the breakeven volume of injections for 2016 using the following formula for the contribution margin ratio approach: Breakeven revenue = Total fixed costs + [(Total variable costs / Total...
-
a) Use the mesh-current method to find the branch currents ????1 ? ????6. b) Test your solution for the branch currents by showing that the total power dissipated equals the total power developed....
-
The Company is Marquet Link- https://www.marquet.cloud/ The CEO of Marquet wants some recommendation of the questions below for a Marketing Plan. 1) What is the expected launch date for marquet? 2)...
-
Impact Monitoring Discussion Board Topic: Review the Strategic Functions table Strategic Functions table - that presents four activities and examples of impact. Briefly discuss the activity (which...
-
For the following game (Player 1 chooses T or B): CR 2,2 0,3 1,2 3,1 1,0 0,2 payoffs L T B (a) (5pts) Find and eliminate any pure strategies that are strictly dominated by mixed strategies. You must...
-
Purchases of goods sold to private entities, gross of 12% VAT Sales to a GOCC, net of 12% VAT Purchases of goods sold to GOCC, net of 12% VAT How much is the withholding VAT? 896,000 1,000,000...
-
Explain and/or show graphically, how the large increase in government spending would impact equilibrium in the IS-LM model. (You would need to clearly show/explain the path not just the result in the...
-
Adams & Co. experienced the following six events in its first year of operations: 1. Shareholders contributed $60,000 cash. 2. Purchased land for $30,000 cash. 3. Borrowed $18,000 in cash from a...
-
If the annual fixed costs are 54,000 dinars, the occupation expense represents 20%, the contribution margin is 25%, and the unit selling price is 40 dinars. Required: Calculate the closing point of...
-
Van makes an investment in a partnership in 2012. Van's capital contributions to the partnership consisted of $30,000 cash and a building with an adjusted basis of$70,000, subject to a nonrecourse...
-
Ken (age 31) and Amy (age 28) Booth have brought you the following information regarding their income, expenses, and withholding for the year. They are unsure which of these items must be used to...
-
Robert Ramos (age 36) is a single taxpayer, living at 8765 Bay Dr., Monterey, CA 93940. His Social Security number is 976-23-5132. Robert's earnings and income tax withholding as the manager of a...
-
LDDS continued to publicly report increasing profits and sales in the financial statements, which allowed it to acquire more companies with no limit to the growth of its stock price. True/False
-
WorldCom overstated its sales by holding its books open at the close of a reporting period. True/False
-
WorldCom overstated its earnings by improper accounting for multiple element contracts. True/False
Study smarter with the SolutionInn App