Some help needed

#include <iostream>
#include <iomanip>
#include <ctime>

using namespace std;

int main()
{

const int rows = 10;
const int colms = 10;

bool land(int location);

int nums[rows] [colms];

cout << " | 0 1 2 3 4 5 6 7 8 9" << endl;
cout << "--+--------------------" << endl;

const int min = 0;
const int max = 1;

srand(time(0));

for(int i = 0; i < colms; i++ )
{
for(int j = 0; j < rows; j++)
{
nums[i] [j] = (rand() % (max - min +1 ) + min);
}
}

for(int i = 0; i < rows; i++)
{
cout << i << " | " ;

for(int j = 0; j < colms; j++)
{

if (nums[ i ] [j] == 0 )
{
cout << " 0" ;
}

else
{
cout << " " ;
}

cout << "Enter (x, y) coordinates: ";
cin >> i >> j;

land = true;
return 3;

if(land == true)
{
return 3;
}

if(land == false)
{
cout << "CRASH! Try again!" << endl;
}



}

cout << endl;

}
}

bool land (int location)
{
if(location == 1)
{
return true;
}

else
{
return false;
}
}
Hi,

Your code with code tags:

http://www.cplusplus.com/articles/z13hAqkS/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

#include <iostream>
#include <iomanip>
#include <ctime>

using namespace std;

int main()
{

const int rows = 10;
const int colms = 10;

bool land(int location);

int nums[rows] [colms];

cout << " | 0 1 2 3 4 5 6 7 8 9" << endl;
cout << "--+--------------------" << endl;

const int min = 0;
const int max = 1;

srand(time(0));

for(int i = 0; i < colms; i++ )
{
for(int j = 0; j < rows; j++)
{
nums[i] [j] = (rand() % (max - min +1 ) + min);
}
}

for(int i = 0; i < rows; i++)
{
cout << i << " | " ;

for(int j = 0; j < colms; j++)
{

if (nums[ i ] [j] == 0 )
{
cout << " 0" ;
}

else
{
cout << " " ;
}

cout << "Enter (x, y) coordinates: ";
cin >> i >> j;

land = true;
return 3;

if(land == true)
{
return 3;
}

if(land == false)
{
cout << "CRASH! Try again!" << endl;
}



}

cout << endl;

}
}

bool land (int location)
{
if(location == 1)
{
return true;
}

else
{
return false;
}
} 


The first thing is to see if compiles, I used cpp.sh, the gear icon at the top right when code tags are used. I turned on all 3 warning levels.


In function 'int main()':
53:6: error: assignment of function 'bool land(int)'
53:6: error: cannot convert 'bool' to 'bool(int)' in assignment
56:12: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
61:12: warning: the address of 'bool land(int)' will never be NULL [-Waddress]
Also, you should actually ask a question. An qualified plea for help probably won't entice someone to answer. Explain what your problem is, post the compiler error & warnings verbatim. Explain what you have done to try and fix the problem.

You could edit your post so it has proper indentation.
Topic archived. No new replies allowed.