Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

looking for code errors 1. Structs and Arrays (2 points) Below is a short code segment which is supposed to read in ints from the

image text in transcribed

looking for code errors

1. Structs and Arrays (2 points) Below is a short code segment which is supposed to read in ints from the user and store them in the array of a bar struct. It prints out the entered numbers and then returns a pointer to the bar struct. Unfortunately, there are a number of errors in this code (compile runtime, and logic). Identify at least 4 and briefly describe each error. i struct foo f 3 int array 2 int size 6 typedef struct bar too; B bar* readArray( 9 bar barr (bar ) salloc sizeof (bar) 10 (fbarr-array)int malloc( sizeof (int) 100) 11 inti-0 12 int temp; 13 14 while scan ttexp) 0)r (fbarr )temp; 15 16 17 18 19 (fbarr).sizei 20 21 printf ("Numbers entered: ) 23 print"d ", fbarr->arrayi]); 24 25 return &fbarr; 26

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Analyse the various techniques of training and learning.

Answered: 1 week ago

Question

4. What actions should Bouleau & Huntley take now?

Answered: 1 week ago