im making a battleship game and so far i have this but im getting an error and i don't know what it means, this is the error error C2664: 'strcpy' : cannot convert parameter 1 from 'char' to 'char *' this is my code

#include <iostream.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
struct coord
{
 int x;
 int y;
};

int main()
{
 int c;
 int x=0;
 char view[7][25];
 coord place[2];

 strcpy(view[0],"            ___________ ");
 strcpy(view[1],"          1| o o o o o |");
 strcpy(view[2],"          2| o o o o o |");
 strcpy(view[3],"          3| o o o o o |");
 strcpy(view[4],"          4| o o o o o |");
 strcpy(view[5],"          5| o o o o o |");
 strcpy(view[6],"           |___________|");
 strcpy(view[7],"             1 2 3 4 5  ");
 cout<<view[0]<<endl;
 cout<<view[1]<<endl;
 cout<<view[2]<<endl;
 cout<<view[3]<<endl;
 cout<<view[4]<<endl;
 cout<<view[5]<<endl;
 cout<<view[6]<<endl;
 cout<<view[7]<<endl;
 
 cout<<""<<endl;
 cout<<"Welcome to battleship"<<endl;
 cout<<"First position your ships, you have 3 ships"<<endl;
 cout<<"Bad idea to put all your battle ships on one coordinate"<<endl;
 cout<<""<<endl;
 do
 {
 for(int i=1;i<4;i++)
 {
  c=i;
 cout<<"Enter the y coordinate you want to place your "<<i<<" ship(1-5)"<<endl;
 cin>>place[i].y;
 cout<<""<<endl;
 cout<<"Enter the x coordinate you want to place your "<<i<<" ship(1-5)"<<endl;
 cin>>place[i].x;
 strcpy(view[place[i].y][place[i].x],"s");[B]//says that the problem is here[/B]
 cout<<""<<endl;
 }
 system("CLS");
 }
 while(x>0);

 cout<<view[1]<<endl;
 cout<<view[2]<<endl;
 cout<<view[3]<<endl;
 cout<<view[4]<<endl;
 cout<<view[5]<<endl;
 cout<<view[6]<<endl;
 cout<<view[7]<<endl;
 cout<<view[8]<<endl;
 
 

 return 0;
}

Recommended Answers

All 2 Replies

>> strcpy(view[place.y][place.x],"s");//says that the problem is here[/b]

That is just a character, not a pointer. same as attempting to do this: strcpy( view[0][0], "S"); If all you want to do is replace the single character then use the assignment operator, not strcpy(); view[place[i].y][place[i].x] = 's';

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.