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
If someone receives a shock, or a piece of equipment is throwing sparks or arcing you should try to pull them away from the sour
vodomira [7]

dancers fault she should try to turn off the power source

6 0
3 years ago
The following code in a different program is not working properly.The message should display the value of the intCounter variabl
frosja888 [35]

Answer:

B

Explanation:

It should be Do While or repeat until and Do until is wrong

5 0
3 years ago
The BCD number for decimal 473 is( ). a) 111011010; b) 010011110011; c) 010001110011; d)0010110110​
jek_recluse [69]

Answer:

001101000111 is the bcd no for 347

8 0
3 years ago
Write a try block in which you prompt the user for an integer and display the name in the requested position in the names array.
N76 [4]

Explanation:

try{

     String[] names={"Tom","Suzie","Lina","Harry","Rosy"};

     Scanner input=new Scanner(System.in);

     System.out.println("Enter an integer: ");

     int position=input.nextInt();

     System.out.println(names[position]);

   }catch(ArrayIndexOutOfBoundsException e){

     System.out.println("Subscript out of range.");

   }

8 0
4 years ago
How do you return a value from a function?
rjkz [21]

Answer:

return instruction used to return a value from a function.

Explanation:

Function is a block of statement which perform the special task.

Syntax for define a function:

type name(parameter_1, parameter_2,...)

{

  statement;

return variable;

}

In the syntax, type define the return type of the function. It can be int, float, double and also array as well. Function can return the array as well.

return is the instruction which is used to return the value or can use as a termination of function.

For return the value, we can use variable name which store the value or use direct value.

4 0
3 years ago
Other questions:
  • What dod regulation governs the use of commercial wireless devices within the global information grid?
    13·1 answer
  • What is heaven backwards?
    11·2 answers
  • According to many experts how often should files be backed up
    12·2 answers
  • #5 Multiple Select Which of the following describes a hardware error? Select 3 options.
    7·2 answers
  • Fill in the code to complete the following function for computing a Fibonacci number. public static int fib(int index) { if (ind
    6·1 answer
  • Host Y sends the first TCP ACK message for the transaction?<br><br> a. true<br><br> b. false
    9·1 answer
  • Write a program that reads the subtotal and the gratuity rate, then computes the gratuity and total. For example, if the user en
    6·1 answer
  • The owner of a candle shop has asked for your help. The shop sells three types of candles as shown below:
    9·1 answer
  • Advantages and disadvantages of a watch tower​
    15·1 answer
  • Technical safeguards involve the hardware and software components of an information system. group of answer choices true false
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!