Solved

Text Color and Sound

Posted on 1998-03-07
4
197 Views
Last Modified: 2006-11-17
How do you change the color of the text that is outputted with a normal output function like cout?
Also, how do you play sound?  I know about cout << '\007'; but there's a function that lets you
change the length and frequency of the sound.
0
Comment
Question by:Jose_G
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 3

Expert Comment

by:q2guo
ID: 1183241
What compiler are your using, on what platform?
0
 

Author Comment

by:Jose_G
ID: 1183242
I don't know why that's important, but Borland C++ 5.01, Win32.
0
 
LVL 3

Expert Comment

by:q2guo
ID: 1183243
For sound, you probably can use

#include <dos.h>

sound(x);
delay(time);
nosound();
where x is the frequency, time is in milliseconds

I am don't sure about changing the color of the output of cout
0
 
LVL 7

Accepted Solution

by:
galkin earned 50 total points
ID: 1183244
To change text color you must obtain device context of the window used as output window. You can get it with GetDC(). Then having HDC you can use SetTextColor. To play sound use PlaySound Win32 API function. Be sure to link your project with winmm.lib
and compiler with mmsystem.h

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C++ finding a sting in a char* string from a text file 3 137
Least Squares Curve Fitting 4 133
How do i run a c++ file? 15 57
C++ help/ Toy problem 19 69
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question