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: 66% (6 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...
-
Developedeffectiveprojectteamsbyimprovingskillsandcompetencies,interaction,motivation, andtrust amongteammembers PEEREVALUATIONFORM:...
-
Plants that grow on Swiss cliffs. Refer to the Alpine Botany (Nov. 2012) study of rare plants that grow on the limestone cliffs of the Northern Swiss Jura mountains, Exercise 2.165 (p. 125). Data on...
-
Police officers of the city of Miami, Florida, responded to reports of a shooting at the apartment of Carlos Fuentes. Fuentes had been shot in the neck and shoulder, and shortly after the police...
-
W5: Reflection Deadline Due by the end of Week 5 at 11:59 pm. ET Directions Auditors financial statements in sessing the fair presentation of a company's financial results. Organizations prepare four...
-
Peachtree Delivery Service is owned and operated by Jerome Foley. The following selected transactions were completed by Peachtree Delivery Service during February: 1. Received cash from owner as...
-
What is a copy constructor?
-
What is a copy assignment?
-
For each of the following pairs of regular languages, find a regular expression and an FA that each define L 1 L 2 : L 1 L 2 (b + ab)*(a + ) (a + ba)*a
-
Explain the principles of database normalization and denormalization, delineating their respective roles in optimizing data storage efficiency, query performance, and data integrity in relational...
-
Asymptotic Computational Complexity O(): Calculate the time complexity of each function below and explain your reasoning. Write your answers on paper and submit a scanned copy. (5 pts each) def...
-
Happy Valley Software has developed a new meteorology software package that will likely revolutionize the weather forecasting industry. They are looking to market the software to the following three...
-
Please read the essay Nasty Women Have Much Work To Do from Alexandra Petri on pages 45-47. In your discussion post, please share your thoughts on what specific strategies she uses to create tone and...
-
We live in an increasingly hyper-competitive global marketplace, where firms are fighting to stay lean and flexible in an effort to satisfy increasingly diverse and specialized consumer demand. In...
-
Sebastian has made contributions of $2000 to his RRSP at the end of every six months for the past eight years. The plan has earned 5.5% compounded semiannually. He has just moved the funds to another...
-
Chao, Louis, and Mari, unrelated individuals, own all of the shares of Cerise Corporation. All three shareholders have been active in the management of Cerise since its inception. In the current...
-
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.
-
A stock is expected to pay a dividend of $1.50 at the end of the year (i.e., D 1 = $1.50), and it should continue to grow at a constant rate of 10% a year. If its required return is 14%, what is the...
-
The Hobby Shop has a checking account with a ledger balance of $1,700. The firm has $2,400 in uncollected deposits and $4,200 in outstanding checks. What is the amount of the disbursement float on...
-
An investment will pay you $34,000 in 11 years. If the appropriate discount rate is 6.1 percent compounded daily, what is the present value? (Use 365 days a year. Do not round intermediate...
Study smarter with the SolutionInn App