Consider what happens if you give strdup(), findx(), and strcmp() an argument that is not a C-style
Question:
Consider what happens if you give strdup(), findx(), and strcmp() an argument that is not a C-style string. Try it! First figure out how to get a char* that doesn’t point to a zero-terminated array of characters and then use it (never do this in real — non-experimental — code; it can create havoc). Try it with free-store-allocated and stack-allocated “fake C-style strings.” If the results still look reasonable, turn off debug mode. Redesign and re-implement those three functions so that they take another argument giving the maximum number of elements allowed in argument strings. Then, test that with correct C-style strings and “bad” strings.
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 60% (5 reviews)
My fake cstyle string of windows reported a length of 20 and as such printed garbage after printing ...View the full answer
Answered By
Sandra Dimaala
Sandra from Philippines ,LICENSED PROFESSIONAL TEACHER.
Teachers are our nation builders—the strength of every profession in our country grows out of the knowledge and skills that teachers help to instill in our children. And, as a nation, we must do much, much more to fully appreciate and support their work.
0.00
0 Reviews
10+ Question Solved
Related Book For
Question Posted:
Students also viewed these Computer science questions
-
Why Vote? Voting is costly. If you vote in person, you have to find your polling place and often stand in line until you get to the voting booth to vote. If you vote by absentee ballot, you have to...
-
You have recently been hired by International Products Inc.s (IPI) internal audit department and are sitting in your office planning for your upcoming meeting with the head of internal audit. It is...
-
Write regular expressions to capture the following. (a) Strings in C. These are delimited by double quotes ("), and may not contain newline characters. They may contain double-quote or backslash...
-
A three-phase line has an impedance of 1 + j3 per phase. The line feeds a balanced delta-connected load, which absorbs a total complex power of 12 + j5 k VA. If the line voltage at the load end has...
-
Evidence indicates that fathers are more likely to take family leave when it is offered as a "father's quota" rather than when it is available as part of a more standard leave policy where the leave...
-
Matusek Corporation has been experiencing a higher than expected number of warranty claims in the current year, due mainly to less than ideal product design. For this reason, the warranty expense...
-
You roll a die. Find the probability of each event. (a) Rolling a 6 or a number greater than 4 (b) Rolling a 2 or a prime number (c) Rolling a number less than 5 or an odd number
-
The before-tax income for Lonnie Holdiman Co. for 2014 was $101,000 and $77,400 for 2015. However, the accountant noted that the following errors had been made: 1. Sales for 2014 included amounts of...
-
Explore and discuss the provisions and requirements of legislation or international standards such as the Payment Card Industry - Data Security Standard (PCI-DSS) Official PCI Security Standards...
-
Express the function in the form f g. u(t) = tan t/1 + tan t
-
What is a copy constructor?
-
What is a copy assignment?
-
Describe five structural configurations for organizations.
-
Find the average and instantaneous rates of change of the functions in Problems 33-36. \(f(x)=5\) a. average for \(x=-3\) to \(x=3\) b. instantaneous at \(x=-3\)
-
In Problems 21-38, guess the requested limits. \(\lim _{n ightarrow \infty} \frac{3 n^{2}+1}{2 n^{2}-1}\)
-
Find the area under the curves in Problems 33-40 on the given intervals. \(y=x^{2}\) on \([1,9]\)
-
Find the area under the curves in Problems 33-40 on the given intervals. \(y=x+3\) on \([1,3]\)
-
Find the area under the curves in Problems 33-40 on the given intervals. \(y=x^{2}\) on \([2,5]\)
-
Kerron Company is presented with the following two mutually exclusive projects. The required return for both projects is 15 percent. Year _________Project M ___________Project N 0 .....................
-
Consider a game of poker being played with a standard 52-card deck (four suits, each of which has 13 different denominations of cards). At a certain point in the game, six cards have been exposed. Of...
-
We say that a router in DVMRP creates a shortest-path tree on demand. What is the meaning of this statement? What is the advantage of creating shortest path trees only on demand?
-
In the network of Figure 21.17, find the shortest path trees for router R if the network is using MOSPF with the source connected to the router marked as S. Assume that all routers have interest in...
-
Does RPF actually create a shortest path tree? Explain.
-
After the company issues an initial public offering and they desire to offer additional shares, one option is the seasoned equity offering. What are the differences between a convertible bond and a...
-
4. A stock provides a dividend yield of 5.0% paid semi- annually. The spot price of the stock is currently $500, and the risk-free rate is 7.5% with continuous compounding for all maturities. 1. What...
-
1. A 1000 bond issued on January 10, 2021 is paying coupons at a nominal interest rate of 7% payable semiannually. The bond is redeemed at par and matures on January 10, 2031. The nominal yield rate...
Study smarter with the SolutionInn App