Write the function prototype for a function with two string parameters that returns a boolean.
时间: 2024-02-16 21:13:10 浏览: 143
The function prototype would look like this:
```
bool stringCompare(const char* str1, const char* str2);
```
This function takes two string parameters (`str1` and `str2`) and returns a boolean (`true` if the strings are equal, `false` otherwise). The `const` keyword is used to indicate that the function will not modify the input strings.
相关问题
Enter your answers into the text box below. a) Given the following: float data[54]; Write a line of C++ code that causes an “out of bounds” problem. [1 marks] b) Write the function prototype for a function with two string parameters that returns a boolean. [2 marks] c) Write a few lines of C++ code to show an example of an infinite loop. Explain why it is an infinite loop [2 marks] d) Given the following: string s; s = "Good evening"; What is the integer value stored in s[3] ? [2 marks]
a) `data[54] = 0;` will cause an out of bounds problem as the array `data` has a size of 54, meaning the last index is 53. Accessing index 54 will result in undefined behavior.
b) `bool functionName(string param1, string param2);`
c) Example code for an infinite loop:
```
while (true) {
// code here
}
```
This is an infinite loop because the condition `true` will always be true, causing the loop to continue indefinitely.
d) The integer value stored in `s[3]` is the ASCII value for the character 'd', which is 100.
阅读全文