How to use gotoxy() and textcolor() in C++

谁说我不能喝 提交于 2020-01-06 20:08:55

问题


I'm using Codeblocks to coding my things using C++.

I remember that in C i can use gotoxy() features and textcolor(), but in C++ that library doesn't work.

Any idea?...

How can i use those functions in C++?.


回答1:


gotoxy() and textcolor() are system dependent functions. They are not part of the standard and not portable.

Two possibilities:

  1. with the same development environment you can get them to work in C and not in C++. In this case, its certainly conio2.h which doesn't provide for extern "C" for the C functions. The linker will not find them for this reason.

  2. with your new development environment these functons are not provided:

    • If you're under windows, you can have a look at this SO question to see how to create your own.
    • If you're under Linux, you'd better have a look at the curses/ncurses library. Or use it to emulate gotoxy() as explained here.


来源:https://stackoverflow.com/questions/33617109/how-to-use-gotoxy-and-textcolor-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!