Correct mistakes in the following program: /* BUG ZONE!!! Example: some common pointer errors */ #include <stdio.h> main() { int i...

90.2K

Verified Solution

Question

Programming

Correct mistakes in the following program:

/* BUG ZONE!!!

Example: some common pointer errors */

#include

main()

{

int i = 57;

float ztran4;

int track[] = {1, 2, 3, 4, 5, 6}, stick[2][2];

int *nsave;

/* Let's try using *nsave as an int variable, and set it to 38*/

*nsave = 38; /* BUG */

nsave = NULL;

*nsave = 38; /* BUG */

nsave = 38; /* BUG */

&nsave = 38; /* BUG */

nsave = &i;

*nsave = 38;

nsave = &ztran4; /* BUG */

nsave = track; /* nsave points at track[0] */

/* Increase track[0] by 1: */

*nsave++; /* BUG */

/* Now point at stick: */

nsave = stick; /* BUG */

nsave = &stick; /* BUG */

nsave = stick[0][0]; /* BUG */

nsave = *stick;

nsave = **stick; /* BUG */

nsave = stick[0];

nsave = &stick[0][0];

nsave = &**stick;

}

Answer & Explanation Solved by verified expert
4.1 Ratings (702 Votes)
include main int i 57 float ztran4 int track 1 2 3 4 5 6 stick22 int nsave int q 38 For assigning 38 to variable otherwise it would    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students