Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C++ text
#11
Quote:Because C++ is like a virus. Once it get's in your system you can't even look at FreeBASIC again... Sad
It can't be a virus...viruses are small, C++ is bloatware extremis. Tongue
\__/)
(='.'=) Copy bunny into your signature to
(")_(") help him gain world domination.
Reply
#12
i know Qbasic quite well!
i want to learn a new language and
join the 21st century!
t is better to error on the side of caution
than the side of haste!!!
[Image: title3.jpg]
Reply
#13
Quote:
cha0s Wrote: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

Huh?
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#14
Code:
#include <iostream>
#include <windows.h>   // WinApi header

#define Ccolor SetConsoleTextAttribute
using namespace std;    // std::cout, std::cin


int main()
{
        // Doent know what it does
        // just need it to set color on screen
        // k can be 1-15, or higher for back ground colors
        HANDLE  sc;
        sc=GetStdHandle(STD_OUTPUT_HANDLE);
        int k= 13;
        Ccolor(sc, 12);
        cout <<"1:" ;
        Ccolor(sc, 10);
        cout <<" Home" << endl;
        Ccolor(sc, 12);
        cout <<"2:" ;
        Ccolor(sc, 10);
        cout <<" End" << endl;
        cin.get(); // wait
        return 0;
}
i found how to do it properly!
Code:
SYSTEM("color 12");
this made the whole screen color 12

but the presiding code will put your text color as many times
as you want on screen!
t is better to error on the side of caution
than the side of haste!!!
[Image: title3.jpg]
Reply
#15
Quote:Huh?

I was speaking from personal experience...when was the last time i used FB again??? Sad Sad Sad
url=http://www.sloganizer.net/en/][Image: style4,TheDarkJay.png][/url]
Reply
#16
phycowelder...if you are on Windoze...I created a function cout(x,y) that behaves like, in QB, locate(x,y): print.

It's easy to use. The solution uses namespaces, so the function as written here is my::cout()

my_cout.h
Code:
#include <iostream>
#include <iosfwd>

#ifndef MY_COUT
#define MY_COUT


namespace my {  
   void locate(int x, int y );  
   std::ostream& cout( int x = -1, int y = -1 );// {  
   void cls();  
   void wait();

}  


#endif //MY_COUT

my_cout.cpp
Code:
#include "my_cout.h"

#include <windows.h>  

void my::locate(int x, int y )  
{  
COORD cur = { x, y };  
SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), cur );  
}  


#include <string>
void my::cls(){
   static const std::string b(2000, ' ');
   my::cout(0,0) << b;
   my::locate(0,0);
}



std::ostream& my::cout( int x/* = -1*/, int y/* = -1*/ ) {  
   if(~x || ~y){
      my::locate(x,y);  
   }
   return std::cout;  
}

void my::wait(){
    std::cin.get();
}

testdriver.cpp
Code:
#include "my_cout.h"

using namespace my;



int main(){
   cout() << "my::cout() behaves just like std::cout\n";
   cout() << "with letters following the cursor";
   wait();
   cout(20,12) << "but you can use the function with arguments";
   cout(20,13) << "to print to arbitrary coordinates";
   wait();
   cls();
   cout(0,0) << "All";
   wait();
   cout(76, 0) << "you";  
   wait();
   cout(75, 23) << "need";
   wait();
   cout(0,23) << "is";
   wait();
   cout(38, 12) << "love";


   wait();
   cls();

   cout(25, 12) << "goodbye cruel world";


   cout(0,24) << "Press Enter to continue";
   std::cin.get();

   int t=clock();
   for(int z=0; z<100; z++){
      cout(z%80, z%25) << z;
      cls();
   }
   t=clock()-t;
  
   cls();
   int t2=clock();
   for(int z=0; z<100; z++){
      cout(z%80, z%25) << z;
      system("cls");
   }
   t2 = clock() - t2;
   cls();
   cout()<< "my::cout is " << t2/t << " times as fast as std::system(\"cls\")" << std::endl;

   wait();
   return 0;

}

Hope this is useful to someone...
Reply
#17
thanx man!
i was trying to figure one out my self!
but it sucked, i doent understand C++ yet
there are alot of functions and opps i doent know what they do yet!

i need to get me a C++ REF now!
t is better to error on the side of caution
than the side of haste!!!
[Image: title3.jpg]
Reply
#18
I highly recommend ISBN 0-07-222722-2 - it's one of the most useful books I've ever bought. I always have it nearby.
img]http://www.cdsoft.co.uk/misc/shiftlynx.png[/img]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)