gpt4 book ai didi

c++ - SDL中如何实现转义序列

转载 作者:行者123 更新时间:2023-11-28 03:53:30 26 4
gpt4 key购买 nike

我正在尝试使用 SDL 中的 STL 库。但它给了我错误
"undeclared identifier"有什么办法可以使用 "\n"甚至 cout<<endl;可以函数SDL_WarpMouse将鼠标光标放在屏幕上的所需位置可以帮助我解决这个问题。因为我想在下一个线序上放一个瓦片。
我希望你得到这个问题。不过,它的问题非常模糊和困惑(对此感到抱歉)。

编辑:

void putMap(SDL_Surface* tile, SDL_Surface* screen)
{
for(int y = 0; y < 21; y++)
{
for(int x = 0; x < 60; x++)
{
if(maze[x][y] != '#')
{
apply_surface( x*10 , y*10 , tile, screen);
}
}
cout<<endl;
}
}

c:\documents and settings\administrator\my documents\visual studio 2008\projects\craptest\craptest\main.cpp(605) : error C2065: 'cout' : undeclared identifier

c:\documents and settings\administrator\my documents\visual studio 2008\projects\craptest\craptest\main.cpp(605) : error C2065: 'endl' : undeclared identifier

这是我的 apply_surface 函数。

void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination )
{
//Make a temporary rectangle to hold the offsets
SDL_Rect offset;

//Give the offsets to the rectangle
offset.x = x;
offset.y = y;

//Blit the surface
SDL_BlitSurface( source, NULL, destination, &offset );
}

最佳答案

coutendlstd 命名空间中并且必须被限定:

std::cout << std::endl;

或者,您可以使用 using 声明:

using std::cout;
using std::endl;

cout << endl;

关于c++ - SDL中如何实现转义序列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4540138/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com