Need help identifying errors please

I am having some trouble on this, can you you help please?


Identify 5 errors, syntax or logic, and give reasons why they are errors in the following program (line number given for identification are not part of program syntax):

1 #include <iostream>

2 #include <cstring>

3 using namespace std;

4 void showValues(char );

5 int main()

6 {

7 char array[3] = {‘s’, ‘t’, ‘o’, ‘p’, ‘\0’}, str[20];

8 str = array;

9 showValues(str);

10 return 0;

11 }

12 void showValues(char str[])

13 {

14 int count;

15 while (str[count] != ‘\0’)

16 {

17 cout << str[count];

18 count++;

19 }

20 if (count == strlen(str)

21 cout >> "Cool";

22 }
the only one i see so far is 21 should be cout <<
and 8 string strArray[]
Last edited on
closed account (EwCjE3v7)
Number 7 array can only have 3 characters not 5.
8 because array was never defined due to error
9 because showValue takes a char
And 21 should be court << "Cool";
Topic archived. No new replies allowed.