Question 3 : Dynamic Memory Allocation ... 10 points For this question you will write code for the following function: c

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Question 3 : Dynamic Memory Allocation ... 10 points For this question you will write code for the following function: c

Post by answerhappygod »

Question 3 Dynamic Memory Allocation 10 Points For This Question You Will Write Code For The Following Function C 1
Question 3 Dynamic Memory Allocation 10 Points For This Question You Will Write Code For The Following Function C 1 (58.02 KiB) Viewed 46 times
Question 3 : Dynamic Memory Allocation ... 10 points For this question you will write code for the following function: char* onlyDigits (char *str) This function returns a dynamically created new string which contains only the digits from the given string. Some examples: onlyDigits("(210)555-1337") should return a new string 2105551337". onlyDigits("pi = 3.14159...") should return a new string 314159". onlyDigits("HelloWorld") should return a new string *** Make sure the new string has exactly enough size to store the digits in a string (i.e., don't malloc more memory than you need). If your malloc fails, your function should call erit(-1). The only functions you should call are malloc, sizeof, erit, is Digit, and strlen. char* onlyDigits (char *str) { 1/Declare variables 1/Find the number of digits (Hint: use a loop) //Malloc and fill string //Return your string }
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply