1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
amm1812
3 years ago
7

Explain what the problems with the implementation of the function are, and show a way to fix them.// return true if two C string

s are equalbool match(const char str1[], const char str2[]){bool result = true;while (str1 != 0 && str2 != 0) // zero bytes at ends{if (str1 != str2) // compare corresponding characters{result = false;break;}str1++; // advance to the next characterstr2++;}if (result) {result = (str1 == str2); // both ended at same time?}return( result );}int main(){char a[10] = "pointy";char b[10] = "pointless";if (match(a,b)){cout << "They're the same!" << endl;}}
Computers and Technology
1 answer:
Nataly [62]3 years ago
7 0

Answer:

The code is not dereferencing the pointers. You have to place an asterisk in front of the pointer to read the value the pointer points to.

Explanation:

So "if (str1 != str2)" must be "if (*str1 != *str2)".

likewise:

   while (*str1 != 0 && *str2 != 0)

and

     result = (*str1 == *str2);

You might be interested in
Which of the following solutions should an administrator use to reduce the risk from an unknown vulnerability in a third-party s
ser-zykov [4K]

Answer:

A. Sandboxing

Explanation:

The best solution to apply for this task would be Sandboxing. This is a software management strategy that isolates applications from critical system resources and other programs. In doing so you effectively add a secondary security layer on top of the application in order to prevent any and all malware from entering and damaging your overall system. Thus effectively reducing the risk.

4 0
3 years ago
Horizontal lines should be avoided in photographs t/f
Temka [501]
I belived its true is the answer
3 0
3 years ago
Is a three-prong grounding plug with the third pong broken-off safe to use.
ad-work [718]
What is the answer choices dude
8 0
3 years ago
A small amount of memory stored on the central processor for easy access is called
expeople1 [14]

The answer is : Cache.  It is a small amount of memory stored on the central processor for easy access.  Cache is where active data are placed for easier access, it stores recently used information so that it can be quickly accessed at a later time. Some types of cache are browser cache, disk cache, memory cache, and processor cache.

3 0
3 years ago
Read 2 more answers
As the European powers grew more industrialized, their colonies became very important as sources of A)slave labor. B)raw materia
nadezda [96]
B) Raw materials; As stated, European powers did indeed grow more industrialized, therefore they needed more raw materials. The North provided lumber, spent time whaling, etc.. The South spent time growing cash crops such as rice, cotton, and indigo. 
8 0
3 years ago
Read 2 more answers
Other questions:
  • Which windows tool is used to determine if a dynamic disk is corrupted?
    6·1 answer
  • ​A(n) ____ will hold an online auction buyer’s payment until he or she is satisfied that the item bought matches the seller’s de
    13·1 answer
  • By Carl Sandburg
    6·1 answer
  • “identify the skill in the following scenario” :
    6·2 answers
  • Which symbol is at the beginning and end of a multiline comment block? &amp;&amp;&amp; """ %%% ###
    5·1 answer
  • How do media and networks interact? A. Networks and media work in exactly the same way. B. Media are connected to networks that
    8·1 answer
  • Create a list with 5 numbers and find the smallest and largest number in the list and also the sum and product of the numbers in
    9·1 answer
  • If you give an actual answer I'll give brainliest​
    13·2 answers
  • Use the drop-down menus to match each description with the part of a report where it is located.
    10·1 answer
  • Wilt short answer of the fol<br>What is an operating systeme te ay maglia<br>​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!