Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help with the Dynamic C-Style Strings portion! e Need Help With The Stax e Search Textbook Solutio oregonstate.edu/eecs/fall2017/cs161-001/labs/lab7.pdf allern until the task is complete.

Please help with the Dynamic C-Style Strings portion!
image text in transcribed
image text in transcribed
e Need Help With The Stax e Search Textbook Solutio oregonstate.edu/eecs/fall2017/cs161-001/labs/lab7.pdf allern until the task is complete. Please read more about pair programming and the benefits: Pair Programming Student Handout IS Take 30 minutes and get caught up on anything you didn't compieie in last week's lab and get checked off for Lab 6, and you can get upnnants added to the last lab!!! (4 pts) Understand Pointers/Dynamic Memory Write 3 different functions in C++ to create memory on the heap without causing a memory leak. Hint: You will need to assign the address to a pointer that was created outside the function. Remember, you can return an address or change what a pointer points to (the contents of a pointer) in a function by passing the pointer by reference or by passing the address of the pointer What if you want to change the contents of what the pointer points to? Make a function that will set the contents of the space on the heap. Do you still need to pass by reference or the address of the pointer? Why or why not? How will you delete the memory off the heap? Try doing it outside a function, now inside a function. Make sure your delete function is setting your pointer back to NULL, since it is not supposed to be pointing anywhere anymore. & You can check to see if you have any memory leaks using valgrind. %valgrind program-exe (3 pts) Static 1-d arrays: C-style Strings Change your implementation from lab #6 to use C-style strings, instead of C++ strings. A C- style string is a string of characters ended by the null character,". Since you don't know how big the message will be, you need to declare a character array large enough to hold a sentence, usually 256 characters will do! This means that the string can hold a maximum of 255 characters, plus one null character

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

Recommended Textbook for

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions