Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C++ text
#1
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!
t is better to error on the side of caution
than the side of haste!!!
[Image: title3.jpg]
Reply
#2
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 )
url=http://www.sloganizer.net/en/][Image: style4,TheDarkJay.png][/url]
Reply
#3
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?
t is better to error on the side of caution
than the side of haste!!!
[Image: title3.jpg]
Reply
#4
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).
img]http://www.cdsoft.co.uk/misc/shiftlynx.png[/img]
Reply
#5
see ncurses or pcurses for mingw.
quote="NecrosIhsan"]
[Image: yagl1.png]
[/quote]
Reply
#6
a test program:
Code:
system("help");

that i found out, it is just using dos/batch file comands!
t is better to error on the side of caution
than the side of haste!!!
[Image: title3.jpg]
Reply
#7
By the way, is your name supposed to be spelt like that? It's not supposed to be 'psychowelder'?
img]http://www.cdsoft.co.uk/misc/shiftlynx.png[/img]
Reply
#8
yes Phyco(F-i-k-o) Welder!
t is better to error on the side of caution
than the side of haste!!!
[Image: title3.jpg]
Reply
#9
why not try FB for simple text manipulation? >.> *spam..*

*spamspam..*
Reply
#10
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
url=http://www.sloganizer.net/en/][Image: style4,TheDarkJay.png][/url]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)