9 Replies - 8715 Views - Last Post: 17 January 2011 - 02:53 PM Rate Topic: -----

#1 SnowLeopard  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 14-January 11

Colored Text as output in C++

Posted 16 January 2011 - 05:07 AM

Hi all, just hoping someone can help. I did 6 months of C++ Turbo programming back in 1996. I now have the time to learn and re-learn. I'm using Windoze XP Pro, & Code::Blocks 10.05 All I want is color output to the screen, to start with.

#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{
  cout<<"\n\n\n";
  textcolor (YELLOW);
  cout<< "********************";
  cin.get();

  return 1;
}



This is my Build Log Error Message...

C:\Documents and Settings\Andrew C. Potts\My Documents\C++ Files\Duh - Hello.cpp: In function 'int main()':
C:\Documents and Settings\Andrew C. Potts\My Documents\C++ Files\Duh - Hello.cpp:9: error: 'YELLOW' was not declared in this scope
C:\Documents and Settings\Andrew C. Potts\My Documents\C++ Files\Duh - Hello.cpp:9: error: 'textcolor' was not declared in this scope
Process terminated with status 1 (0 minutes, 0 seconds)
2 errors, 0 warnings

Any help would be GREATLY appreciated! I am a noobie, but feel I will have a lot to offer once I get rolling again.
In advance... Thank you,
SnowLeopard

And if the band you're in starts playing different tunes, I'll see you on the dark side of the moon.

This post has been edited by JackOfAllTrades: 16 January 2011 - 06:23 AM
Reason for edit:: Fixed code tags


Is This A Good Question/Topic? 0
  • +

Replies To: Colored Text as output in C++

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6110
  • View blog
  • Posts: 23,670
  • Joined: 23-August 08

Re: Colored Text as output in C++

Posted 16 January 2011 - 06:27 AM

textcolor is not a standard C++ function. See this topic for the right way to set color in the console in Windows.
Was This Post Helpful? 1
  • +
  • -

#3 SnowLeopard  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 14-January 11

Re: Colored Text as output in C++

Posted 16 January 2011 - 02:30 PM

View PostJackOfAllTrades, on 16 January 2011 - 06:27 AM, said:

textcolor is not a standard C++ function. See this topic for the right way to set color in the console in Windows.



Thanks SO much for that. Works perfectly (of course!!) I'm not sure where I picked up the 'textcolor' from, but I know where it will be going to!!!

Again, thankyou... SnowLeopard
Was This Post Helpful? 0
  • +
  • -

#4 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Colored Text as output in C++

Posted 16 January 2011 - 08:16 PM

Why are you returning 1 instead of zero to the OS on program termination? :)
Was This Post Helpful? 0
  • +
  • -

#5 eker676  Icon User is offline

  • Software Engineer
  • member icon

Reputation: 378
  • View blog
  • Posts: 1,833
  • Joined: 18-April 09

Re: Colored Text as output in C++

Posted 16 January 2011 - 10:40 PM

I think he is remembering some of the bad habits he learned using Turbo C++.

I would relearn C++ the right way. What you were taught 14 years ago is a bunch of nonstandard junk. Maybe not all of it.. but using textcolor() suggests most of it was.

This should help get you up and running:
http://cplusplus.com/doc/tutorial/
Was This Post Helpful? 1
  • +
  • -

#6 SnowLeopard  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 14-January 11

Re: Colored Text as output in C++

Posted 17 January 2011 - 01:43 PM

View PostButchDean, on 16 January 2011 - 08:16 PM, said:

Why are you returning 1 instead of zero to the OS on program termination? :)


I'm not too sure why I was returning 1 instead of zero... What I had previously learnt with Turbo didn't even have a return... Plus, cin & cout were not around - they were printf and scanf. So, bad habits are now broken, and I'm re-learning at a great pace.
Thanks for the reply,

SnowLeopard
Was This Post Helpful? 0
  • +
  • -

#7 SnowLeopard  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 14-January 11

Re: Colored Text as output in C++

Posted 17 January 2011 - 01:52 PM

View Posteker676, on 16 January 2011 - 10:40 PM, said:

I think he is remembering some of the bad habits he learned using Turbo C++.

I would relearn C++ the right way. What you were taught 14 years ago is a bunch of nonstandard junk. Maybe not all of it.. but using textcolor() suggests most of it was.

This should help get you up and running:
http://cplusplus.com/doc/tutorial/

RE: I think he is remembering some of the bad habits he learned using Turbo C++.

I would relearn C++ the right way. What you were taught 14 years ago is a bunch of nonstandard junk. Maybe not all of it.. but using textcolor() suggests most of it was.

Definitely bad habits & non-standard coding. Somegood came out of it, but I'm certain;y re-learning standardized C++ coding now. And thanks for the link, it is exactly what I've been searching for! Cheers for now,
SnowLeopard
Was This Post Helpful? 0
  • +
  • -

#8 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Colored Text as output in C++

Posted 17 January 2011 - 02:05 PM

Don't worry, SnowLeopard, I'm sure JackOfAllTrades will single handedly get your standards back on track! :D
Was This Post Helpful? 0
  • +
  • -

#9 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6110
  • View blog
  • Posts: 23,670
  • Joined: 23-August 08

Re: Colored Text as output in C++

Posted 17 January 2011 - 02:50 PM

Who me? :D

Actually, if you're using C++ then there is no need to return a value per se; there is an implicit return of 0 to the caller.
Was This Post Helpful? 0
  • +
  • -

#10 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Colored Text as output in C++

Posted 17 January 2011 - 02:53 PM

View PostJackOfAllTrades, on 17 January 2011 - 09:50 PM, said:

Who me? :D

Actually, if you're using C++ then there is no need to return a value per se; there is an implicit return of 0 to the caller.

I rest my case. :hungry: :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1