Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Date: August 22, 2017, 4:13 PM Description: Demonatration of debogging (there is

ID: 2247321 • Letter: D

Question

Date: August 22, 2017, 4:13 PM Description: Demonatration of debogging (there is a bug in the code) include include catdlib.h> include Descriptionimain funetion Receives: Nothing Returns: Exit status Requires: Nothing int main (void) char "myString "This is my string!" char *buffer, int myInt 0x11223344 int strSize int value // Get the nunbez of characters in the steing strsize strien (nystzing) printt ("The size ot mystring is td. n", strsize) Allocate nemory tor butter, make it a bit larger than needed buffer malloc(strlen (myString)10) Pi11 the buffer with known values value 0x41 butfer[4]-value 1Copy value, then incremens value // Now copy myString strncpy (bufter, nystring, stesLz0) // Peint resuits printf ("Original string: bai, mystring)a printr("copy of string: oin", butter)s / Print the first byte of myint printf ("The first byte of nyine " %hhah". nyInt), // Tree up the menory we allocated free (buffer) return (EXIT SUCCESS) MacBook Pro 5 6 3 3

Explanation / Answer

answer:

4th question answer is buffer has text at the end because allocated size of the string is to be define in for loop so that we don't have any null character the end of the string.

5th question answer is make buffer to be size indicated by the strsize because the more repeated to of the for loop with the highest string size so doesn't accommodate the another characters of the string.

**Thanking you ask any queries regarding this**

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote