I was wondering if theres a way to have a maximum ammount of characters when using cin, also is there a way to change the text color, and the background color of the command prompt window?
I was wondering if theres a way to have a maximum ammount of characters when using cin, also is there a way to change the text color, and the background color of the command prompt window?
I tried to find a definite answer for this, but it depends on what type of an identifier you're reading into. You could do some tests to check how many digits you can read into an int, or how many characters you could read into a string, for example.
if your identifier is an char, well then you could read only a single character.
some entropy with that sink? entropysink.com
there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka
Check MSDN.com. With <windows.h> included, you can change text colors and such, I believe.
And the way to have a max amount of characters is cin.getline(string,MAX,term_char)
Code:cin.getline(myString,100, '\n');
And once again, the FAQ comes to the rescue!
As to the first question, I am not sure, but my guess is that the answer lies somewhere in numeric_limits.
The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.
I did try using the textcolor function, but I get errors when I compile. Im using Microsoft Visual C++.Originally Posted by Zach L.
Dont see whats wrong here.
Code:#include <iostream> #include <stdio.h> #include <conio.h> #include <stdlib.h> using std::cout; using std::cin; char command; int ch; // Inpute Function. checks all input. void inpute() { textcolor ( MAGENTA ); cprintf ( ">> \n" ); cprintf ( ">> " ); }
I get these errors
Code:c:\documents and settings\blade-new\my documents\visual studio projects\admin\funcs.h(12) : error C2065: 'textcolor' : undeclared identifier c:\documents and settings\blade-new\my documents\visual studio projects\admin\funcs.h(12) : error C2065: 'MAGENTA' : undeclared identifier Error executing cl.exe. ADMIN.exe - 2 error(s), 0 warning(s)
I see, you clicked on the link, but have not read it thoroughly enough...look for the windows platform color change
some entropy with that sink? entropysink.com
there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka
Oh, yes I see, but theres only 3 colors . Thanks though
You can mix them.Originally Posted by bladerunner627
Stupid things pop singers say
"I get to go to lots of overseas places, like Canada."
- Britney Spears
"I love what you've done with the place!"
-Jessica Simpson upon meeting the Secretary of Interior during tour of the White House
How exactly?Originally Posted by fuh
Use the bitwise-or operator.Originally Posted by bladerunner627
Code:SetConsoleTextAttribute ( h, FOREGROUND_RED | FOREGROUND_BLUE );
If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein