C/C++ :: How To Give A Color To The Text That Displayed In Output Screen
Jan 27, 2013i am using c++v30.5 version i want red color text in in my output screen . i viewed various site but the result is 0 ,wat to do?
View 2 Repliesi am using c++v30.5 version i want red color text in in my output screen . i viewed various site but the result is 0 ,wat to do?
View 2 RepliesHow I can clear the whole screen in console...
And I'm using clrscr(); and its not working.
How i can change the text color in the .exe without using system function
I'm trying to determine (from my Win32 process) if a Metro (or a Modern UI) app is currently displayed on the screen. I found the IAppVisibility::GetAppVisibilityOnMonitor method that can do just that, and I even found a C++ sample, but my issue is that I'm compiling it with the Visual Studio 2008 that does not have the definitions for the IAppVisibility interface, so the following:
Code:
#include <Shobjidl.h> //Earlier version
IAppVisibility* pAppVis = NULL;
HRESULT hr = CoCreateInstance(CLSID_AppVisibility, NULL, CLSCTX_INPROC_SERVER,
IID_IAppVisibility, (void**) &pAppVis);
Results in a set of errors:
Code:
error C2065: 'IAppVisibility' : undeclared identifier
error C2065: 'IID_IAppVisibility' : undeclared identifier
how to define them?
I am in the process of writing a program that will give the appropriate color code for a resistor after the user enters an integer value for the resistance needed and selects the tolerance form a list. My question is this: Is there a way to allow the user to enter a value such as 75000 and C++ use each digit separately, as if they entered 7 [enter], 5[enter], 0 [eneter]... and so on? But, then use the entire value as an integer too? Also, it should read a value such as: 45835, as 45000, or 1843 as 1800.
View 1 Replies View Relatedwhy my data is not being displayed in my text box. I have no compiling errors and it seems as if my program isnt doing anything.
Here is my code:
#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
[Code].....
I'm trying to build a basic shell for Unix. This is the code I use to create a new process:
Code:
pid = fork();
if (pid == 0) {
setpgrp();
complexCommand(argv, isComplex);
[code] .....
Where complexCommand is a function that handles the command (uses execvp after generating the correct string out of argv). My problem is that after if while in the shell I use a program that needs to print to the screen and handle input, it doesn't work as expected. To test this, I built this small program:
Code:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
int main() {
int x1, x2;
[code] ....
And when I use the shell I built to run it, the output is only "Enter 2 numbers" for one time. It doesn't print the result, or anything else. Is there anything I need to do in the parent process (my shell in this case) to give the child the output?
I'm creating a bank system.
So I know to make a deposit to the balance, which add ups what is the balance to i have add.
When i run the deposit function, its work well in some ways. If balance(text file) has the value 10, add i addSum 20, the balance will become 30, same as the text file will become 30. so its work well to add positive number.
Code:
double deposit(double balance) {
double addSum = 0;
system("CLS");
cout<< "Welcome to deposit."<<endl;
cout<<"Enter a sum you wish to add to your account:";
[code]...
When I withdraw from 30 which is the balance, then i takeSum, for example i take away 30. The balance will become 30 - 30 = 0 When i make another withdraw from example -150, it will be -150.Which shows correct.
But when i make a deposit from -150 and i addSum 130, the balance shows -500, and it should had been -20.
Code:
double withdraw(double balance) {
double takeSum = 0;
system("CLS");
cout<< "Welcome to withdraw."<<endl;
cout<<"Enter a sum you wish to take away from your account:";
[code]...
What the issue is with my algorithm, though it seems to match others that are out there. I believe the output is wrong for what it should be.
Input:
50 50 50
0 0 0
255 255 255
0 100 100
200 200 0
150 0 150
300 0 0
1 1 1
0 0 245
Code:
#include <iostream>
#include <fstream>
using namespace std;
void isValid(int, int, int);
float maximum(float, float, float);
void RGBtoCMYK(float, float, float, float &, float &, float &, float &);
[Code] .....
Output:
0 0 0 0.803922
0 0 0 1
0 0 0 0
1 0 0 0.607843
0 0 1 0.215686
0 1 0 0.411765
0 1 1 -0.176471
0 0 0 0.996078
1 1 0 0.0392157
what I'm trying to do is output a certain string depending on the color I see in the video feed. For right now, what I've done is threshold the feed so that everything above a certain brightness shows up as Red. Now I want to have something that says if there's any red in the feed, then I output a "1" to a text box on my user interface that's showing the feed. If there is no red, then I output a "0" to the text box.
I'm using Emgu CV C ++ with VS2010.
This is the code I have so far that isn't working correctly, it's giving me a compiler error.
cvConvertScaleAbs(frameFromCamera->Ptr.ToPointer(),frameDisplay->Ptr.ToPointer(),double(1)/16,0);
cvCvtColor(frameDisplay->Ptr.ToPointer(),frameColorDisplay->Ptr.ToPointer(),CV_GRAY2BGR);
cvThreshold(frameDisplay->Ptr.ToPointer(),maskSaturated->Ptr.ToPointer(),200,255,CV_THRESH_BINARY);
[Code] .....
and the error it's giving me
BAOTFISInterface.cpp(1010): error C2664: 'Emgu::CV::Image<TColor,TDepth> ^Emgu::CV::Image<TColor,TDepth>::InRange(Emgu::CV::Image<TColor,TDepth>
^,Emgu::CV::Image<TColor,TDepth> ^)' : cannot convert parameter 1 from 'Emgu::CV::Structure::Bgr *' to 'Emgu::CV::Image<TColor,TDepth> ^'
[Code] .....
Build FAILED.
How do i change color of text in the program more than once . rite now i use the code
system ("color 0c");//makes the color of the text red
cout <<"hey";
system ("color 02") //change color to green;
cout<<"only in green ";
it displays both the lines in green not the first in red and second in green.
I was trying to change the text and background color to :red blue
Is there a way to do this? is there a certain function? ...
I have turbo c++ on windows xp SP2.....whenever i compile my code in turbo c++ i am getting output outside the screen.....but when i used code::block....i get the correct output...fits to screen ...
View 7 Replies View Relatedwhy I can't output ounces on the screen in c#...here's the code:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Chapter7Problem12
{
class Program
}
[code]....
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
int main()
[code]....
I do not know how to output on the screen, I believe that i have written it to the file correctly but i dont know how to output it.
I want to write a program that makes this output to appear on screen using for-loop :
0 0
1
2
3
4
5
1 0
1
2
3
4
5
2 0
1
2
3
4
5
3 0
1
2
3
4
5
I can't seem to make the correct logic/engine of this nested loop.
I managed to write successfully my code that I have been wanting to write for some years now, but I want to align the text that is displayed in the output screen but I haven't been able to. I've tried adding and taking away numbers from the identifiers but nothing.
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#define ARRAYSIZE 2
#define FORMAT "First Name Pago1 Pago2 Pago3 Pago4 Total Net"
#define FORMATHEADER "Last Name "
[code].....
I try to change the text color of console in C++. I know some commands like .
system("color fg");
But I want to change the color of only one line of console. Is this possible?
I've tried this (without success):
ui->tableView->model()->setData(ui->tableView->model()->index(5, 5, QModelIndex()), QVariant(QColor(Qt::red)), Qt::DecorationRole);
how to display an image on the output screen of c++ program.
I am using : Turbo c++(dos box) on win8
I am having trouble outputting the file "output1.dat" to the screen. here is my code -
#include <fstream>
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
//Outputs a description of what this program does
void intro();
void sort_merge(ifstream& in_1, ifstream& in_2, ofstream& out_1 );
[Code] .....
I have a derived CComboBox class, where I tried to change text and background of edit from CComboBox, just like this:
Code:
HBRUSH CMyComboBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) {
HBRUSH hbr = CComboBox::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
//if(CTLCOLOR_EDIT == nCtlColor || CTLCOLOR_MSGBOX == nCtlColor) {
[Code] ......
but is not working if CComboBox has CBS_DROPDOWNLIST style ... is working only for CBS_DROPDOWN style ... why ?
How can I make the output print out to the screen in reverse?
Code: #include <iostream>
#include <iomanip>
using namespace std;
int getnum();
void Fibonacci(int n);
[Code].....
/* This is what I have so far what i am trying to do is to initialize the arrays at zero and output the board to the screen. Part of the problem is the user has the option of the board size. All this is suppose to do is to output the board to the screen. I am having problems understanding 2D Arrays.
*/
using namespace std;
int main() {
const int BOARD_MAX = 10; // Maxinum Board size.
const int BOARD_MIN = 3; // Minimum Board size.
array = [COL];
array [ROW];
[Code] ....
I needed to change Default Text attributes (font and color) . So I wrote following code , UnicodeTextOut function. I called this function once in each 55ms to update the display screen. but I observed that my Screen used to become grey like a crash after sometime . If I use Minimize an Maximize window , the screen was restoring back for some time.
When I thought over the code , I got my mistake that CreateFont initialization should be done once in the program and probably outside the function.
void UnicodeTextOut(int x, int y, CString s, UINT justify,int GreyScaleFlag) {
HFONT hFontUnicode;
HFONT hfOld ;
hFontUnicode = CreateFont(16, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0, _T("Aerial"));
[Code] ....
Then I shifted the line hFontUnicode = CreateFont(16, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0, _T("Aerial")); in my screen class constructor and made hFontUnicode global .
This solved my problem as expected. Why a system crash after certain no of CreateFont calls ?
How to configurate color of selected text. I am not sure why, but in Visual C++ it is not displayed as in other programs like notepad, which should be harder color. So I cannot find the selected text. Where can I configurate it or where to search it in desktop theme settings?
View 3 Replies View RelatedI created a C program that extracts some information from computer and displays it on screen. It is completed today and is going to be applied to startup programs of domain machines. It runs at logon and takes somewhat 5-10 seconds to finish execution. The output is shown on console screen & user can either close the window by clicking on 'x' or pressing 'Ctrl+c' during execution. How do i prevent both of these events?
Basically the most time consuming processes are
Code: popen("systeminfo","r");
popen("wmic qfe get installedon","r");
1st command is getting OS name,version and hotfixes installed.
2nd command gives me the date of updates installed.
I then filter out data & print required information only.