cannot convert parameter 1 from 'char [80]' to 'LPCWSTR'
Herearethecodes:#include<stdlib.h>#include<windows.h>#include<stdio.h>#include<iostre...
Here are the codes:
#include<stdlib.h>
#include <windows.h>
#include <stdio.h>
#include <iostream>
using namespace std;
#include "conio.h";
class MyPosition;
class MyScreen
{
public:
void PrintMyPosition(MyPosition* pMyPosition);
};
class MyPosition
{
public:
int x,y;
void DisplayMyPosition(MyScreen* pMyScreen);
};
void MyScreen::PrintMyPosition(MyPosition* pMyPosition)
{
HANDLE hConsoleOutput=GetStdHandle(STD_OUTPUT_HANDLE);
COORD dwCursorPosition={1, 10};
char sz[80];
sprintf(sz, "My position is (%d,%d).", pMyPosition->x, pMyPosition->y);
DWORD cWritten;
WriteConsoleOutputCharacter(hConsoleOutput, sz, lstrlen(sz),dwCursorPosition, &cWritten);
dwCursorPosition.X=pMyPosition->x;
dwCursorPosition.Y=pMyPosition->y;
SetConsoleCursorPosition(hConsoleOutput,dwCursorPosition);
}
void MyPosition::DisplayMyPosition(MyScreen* pMyScreen)
{
pMyScreen->PrintMyPosition(this);
}
void main()
{
MyPosition mypos;
MyScreen mysrn;
cout<<"Enter a position (e.g. 4 10): ";
int x,y;
cin>>x>>y;
mypos.x=x;
mypos.y=y;
mypos.DisplayMyPosition(&mysrn);
getch();
}
I am fresh man in C++,
Thanks so much! 展开
#include<stdlib.h>
#include <windows.h>
#include <stdio.h>
#include <iostream>
using namespace std;
#include "conio.h";
class MyPosition;
class MyScreen
{
public:
void PrintMyPosition(MyPosition* pMyPosition);
};
class MyPosition
{
public:
int x,y;
void DisplayMyPosition(MyScreen* pMyScreen);
};
void MyScreen::PrintMyPosition(MyPosition* pMyPosition)
{
HANDLE hConsoleOutput=GetStdHandle(STD_OUTPUT_HANDLE);
COORD dwCursorPosition={1, 10};
char sz[80];
sprintf(sz, "My position is (%d,%d).", pMyPosition->x, pMyPosition->y);
DWORD cWritten;
WriteConsoleOutputCharacter(hConsoleOutput, sz, lstrlen(sz),dwCursorPosition, &cWritten);
dwCursorPosition.X=pMyPosition->x;
dwCursorPosition.Y=pMyPosition->y;
SetConsoleCursorPosition(hConsoleOutput,dwCursorPosition);
}
void MyPosition::DisplayMyPosition(MyScreen* pMyScreen)
{
pMyScreen->PrintMyPosition(this);
}
void main()
{
MyPosition mypos;
MyScreen mysrn;
cout<<"Enter a position (e.g. 4 10): ";
int x,y;
cin>>x>>y;
mypos.x=x;
mypos.y=y;
mypos.DisplayMyPosition(&mysrn);
getch();
}
I am fresh man in C++,
Thanks so much! 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询