C ++图形功能! [英] C++ graphics function!
本文介绍了C ++图形功能!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
puttextxy(int x,int y,string str);
如何像我们一样使用字符串参数printf()函数。
我的意思是说我要插入一个字符串,如 printf(%d,var) can我对 puttextxy()的字符串参数使用相同的语法 function
puttextxy( int x, int y, string str);
How can I use the string arguments as like we do in printf() function.
I mean to say that I want to insert a string like printf("%d",var) can I use same syntax for string argument of puttextxy() function
推荐答案
得到答案
Got My Answer
char str[100];
sprintf(str,"(%d,%d)",x,y);
outtextxy(x,y,str);
C库函数 - sprintf() [ ^ ]
你可以在你自己的代码中包装提供的puttextxy函数来提供这个例子
you could wrap the supplied puttextxy function in your own code to provide this eg
Shrikshel_puttextxy(int x, int y, string format, ...)
{
string formatted_str = "";
// form a string using format and varargs from ...
puttextxy(x, y, formatted_str);
}
然后你会把你的日常工作称为: -
you'd then call your routine like :-
Shrikshel_puttextxy(5,10,"%d",150);
你需要阅读使用变量长度参数'varargs'使用'...',但它不太难
you'd need to read up on using variable length arguments 'varargs' using '...' but its not too hard
这篇关于C ++图形功能!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文