Qbasicnews.com

Full Version: C++ text
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I am trying to use what i have learned so far
and make some cheesy TEXT games
making opps functions and stuff
just to drill the basics in to my head!

but looking through both my books
and the net i cant find any info
on basic text manipulation on the screen!
like:

Locating text on the screen
clearing screen
coloring text

i was wondering is there a
built in C++ library to do all that
or do i have to make my own!
I'm sure i can make it my self
but coloring I haven't the foggiest how to change.
and i am surprised my books don't show me!
system("CLS") will clear the screen (std:Confusedystem if you don't put using namespace std; at the start of the code

Code:
void text(string txt, unsigned short int x,unsigned short int y)
{
/////////////////////////////////////////////////////////////////////
//                   --Locate Text Function--                           //
//    Authors: gamehawk (gamehawk@myway.com)        //
//                   Last Modified: 1-09-05                            //
//         http://s9.invisionfree.com/CPPgamedev/           //
///////////////////////////////////////////////////////////////////
int i;
for (i=1;i<y;i+=1){cout<<endl;}
string str="";
for (i=1;i<x;i+=1){str+=" ";}
txt=str+txt;
cout<<txt<<endl;
}

this will SORT OF locate a area on the screen.

Colouring text is quite similar to in FB/QB

Color 15 in Qb is the same as
std:Confusedystem("COLOR 15") in C++

I believe system and cout and stuff are in iostream ( #include <iostream )
thank you!
much appersiated

Just a nother small question!
dou you know of a REFRENCE for system!
in case there are other useful functions
or methods in system i could use?
system( const char* ) just runs a command in the shell. There is no reference.

Also, text formatting and text positioning functions are not standard in C++ because they are device dependent; it's impossible to tell what the width/height of the device you're writing to is (if it has one at all) and it's not possible to tell the colouring mechanism used (e.g. ANSI colour codes in Linux).
see ncurses or pcurses for mingw.
a test program:
Code:
system("help");

that i found out, it is just using dos/batch file comands!
By the way, is your name supposed to be spelt like that? It's not supposed to be 'psychowelder'?
yes Phyco(F-i-k-o) Welder!

Anonymous

why not try FB for simple text manipulation? >.> *spam..*

*spamspam..*
Quote:why not try FB for simple text manipulation? >.> *spam..*

*spamspam..*

Because C++ is like a virus. Once it get's in your system you can't even look at FreeBASIC again... Sad
Pages: 1 2