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
Tyrell is required to find current information on the effects of global warming. Which website could he potentially cite as a cr
Katarina [22]

Answer:

2345

Explanation:

5 0
2 years ago
Read 2 more answers
PLEASE HELP ASAP I WILL GIVE BRAINLIEST TO CORRECT ANSWER
salantis [7]
The correct answer is letter b
8 0
3 years ago
Read 2 more answers
How can anger cause workplace accidents?
Umnica [9.8K]
I think the corect answer is c
8 0
3 years ago
Read 2 more answers
19 POINTS! (Excel) Use the drop-down menus to complete the steps for opening and using the Format Cells dialog box to change fon
Maksim231197 [3]

Explanation: right click and font

5 0
3 years ago
Read 2 more answers
[Please Help ASAP!]
iragen [17]
The answer has to be C
3 0
3 years ago
Other questions:
  • To include totals and other statistics at the bottom of a datasheet, click the ____ button on the HOME tab to include the Total
    12·1 answer
  • If you are making a 30-minute presentation, how much time should be spent summarizing your points and making any closing remarks
    11·2 answers
  • It is used to replace numeric number of a website​
    7·1 answer
  • Prepare a risk assessment report (RAR) with information on the threats, vulnerabilities, likelihood of exploitation of security
    14·1 answer
  • python Consider this data sequence: "3 11 5 5 5 2 4 6 6 7 3 -8". Any value that is the same as the immediately preceding value i
    7·1 answer
  • Several NEC® sections contain the requirement to size conductors and overcurrent devices at 100 percent of the noncontinuous loa
    15·1 answer
  • Why must you be careful when handling a hard drive?
    10·1 answer
  • When writing code, how can printing be useful?
    15·1 answer
  • Write a program that will predict the size of a population of organisms. The program should ask the user for the starting number
    8·1 answer
  • HELP ME PLEASE
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!