Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ thanks 10. As we osian iect ure, arrays are not self-describing because the number of elements of an array is not guaranteed to be

C++ thanks image text in transcribed
10. As we osian iect ure, arrays are not self-describing because the number of elements of an array is not guaranteed to be stored within the array. This implies that an array, the number of elements contained within it must be somehow supplied. In the case of character arrays (C-style strings), each is initialized with one more char- acter than it would otherwise appear to have; this is because character arrays are ter- minated by the null character \o, which has a value of zero. For example, consider the following representations: char bohr [] - "Bohr " :- | B | o | h | r \o char michael []-"Michael". With this in mind, (a) (12 points) Write a complete function definition with return type and signature char* strdup (const char*), that copies each character of the C-style string passed to it into a new character array of the same size allocated on the free store. Your function should return the address of the new C-style string constructed. For full credit, do not use subscripting; use the dereference operator* instead. Do not use any standard library functions

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_2

Step: 3

blur-text-image_3

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

Intelligent Information And Database Systems 6th Asian Conference Aciids 2014 Bangkok Thailand April 7 9 2014 Proceedings Part I 9 2014 Proceedings Part 1 Lnai 8397

Authors: Ngoc-Thanh Nguyen ,Boonwat Attachoo ,Bogdan Trawinski ,Kulwadee Somboonviwat

2014th Edition

3319054759, 978-3319054759

Students also viewed these Databases questions