so, im new here to the forums, but not new to c++. i took visual studio in highschool and c++ in college, but now i've forgoten alot of it.
what im trying to do is make a game of battleships, i set it as my task to get back into coding.
for the actualy game board, i want the screen to display it as so:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
A - - - - - - - - - - - - - - - -
B - - - - - - - - - - - - - - - -
C - - - - - - - - - - - - - - - -
D - - - - - - - - - - - - - - - -
E - - - - - - - - - - - - - - - -
F - - - - - - - - - - - - - - - -
G - - - - - - - - - - - - - - - -
H - - - - - - - - - - - - - - - -
I - - - - - - - - - - - - - - - -
J - - - - - - - - - - - - - - - -
K - - - - - - - - - - - - - - - -
L - - - - - - - - - - - - - - - -
M - - - - - - - - - - - - - - - -
N - - - - - - - - - - - - - - - -
O - - - - - - - - - - - - - - - -
P - - - - - - - - - - - - - - - -
for the numbers at the top i used
int Numbers[128] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
which works fine, but i want to display the rest of it on each successive line with a similar char or string array(s) if possible, but the system dosnt like my attempt at a char array:
char A[128] = { "A", "", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", NULL };
i will change all but the first a to -, but as it is, its giving me the following error on the second a in the list:
char[128]{(char)'A', (char'/000')
too many initializer values
heres the whole code so far, i havnt got very far into it. i've mostly been going off half remembered lessons, google, and trail and error.
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
|
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<conio.h>
#include<stdio.h>
using namespace std;
char A[128] = { "A", "", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", NULL };
int Numbers[128] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
int main()
{
char name[32];
cout << "Welcome to battle shits 1.0" << endl;
cout << "please enter your name:" << endl;
cin.getline (name, 32);
system("CLS");
cout << "welcome " << name << "!" << endl;
cout << "below is displayed the battle shits arena." << endl << endl << endl << endl;
cout << " " << Numbers[0] << " " << Numbers[1] << " " << Numbers[2] << " " << Numbers[3] << " " << Numbers[4] << " " << Numbers[5] << " " << Numbers[6] << " " << Numbers[7] << " " << Numbers[8] << " " << Numbers[9] << " " << Numbers[10] << " " << Numbers[11] << " " << Numbers[12] << " " << Numbers[13] << " " << Numbers[14] << " " << Numbers[15] << " " << endl;
cin.getline(name, 32);
return 0;
}
|