C++ :: Clear Part Of The Screen?
Nov 3, 2014
Is there any way I can clear only a selected part of the screen? (I'm aware of system("cls"))
For example, when you enter a date, and is wrong, could it just errase that input and only say "Wrong try again" without errasing everything else you where doing?
In this case, a function that only errases what is in the while
while(not wrong)
{
cout<<"DIA: ";
cin>>obj.dia;
cout<<"MES: ";
cin>>obj.mes;
cout<<"ANIO: ";
cin>>obj.anio;
}
PS: Also, is there any whay in which you can ask the user to enter the date DD/MM/YYY?
View 1 Replies
ADVERTISEMENT
Nov 4, 2013
I have a one simple question :D. I want to output to the console some symbols. Let's say that i have a loop.
for(int i = 0; i < 10; i++) cou << "* ";
Then I want to output other symbols but I want to overwrite the previous symbols. I know I can use system("cls"); but it blinks if I try to output the same characters. For example if I have:
for(int i = 0; i < 10; i++) cou << "* ";
system("cls");
for(int i = 0; i < 10; i++) cou << "* ";
After I run this code the first loop outputs ten "*". Then there is a blink and there are again ten "*" shown. How can I avoid this blink?
View 4 Replies
View Related
Jan 11, 2013
I checked through the net and most of the solution like clrcr(); is not working for microsoft visual 2010. SO i was wondering for those who was using the same ver of c++ as me how do you clear the screen?
View 5 Replies
View Related
Dec 28, 2013
How 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
View 4 Replies
View Related
Dec 10, 2014
I am working on a simple calculator in C++ .... All works fine with the calculator up until the requirement for the user to input "do you want to go again y/n" .... What i want to happen is the screen to clear down and reloop to the enter name part....but i can't get it to do that
Program Description: To write and develop a programme where a user can input a cost or price of something before VAT our program must then process the input number and must output the price with the original value plus VAT
#include <iostream>// I must use this to start my programming
#include <string> // I have added this for the extension task so the user has to input their name
#include <iomanip> // this is to manipulate the text
#include <stdlib.h>
using namespace std; // using the "using namespace std" shows that i will be using standard text throughout this programme
[Code] .....
View 5 Replies
View Related
Nov 11, 2013
For my C programming module, I've been asked to create a program which is basically a ten question mathematics quiz or test if you like. Below is a copy and paste of my current, working program.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main () {
[Code]....
I am also trying to include into my program; If the user achieves 4 or less marks in the test, they are asked if they would like to repeat the test (have a second chance).
I have been asked by my Lecturer to ask the Question; "Would you like to try again" and the response is 'Y' for yes, 'N' for no. Would this be shown by:
char Y = Y;
char N = N;
printf("Would you like another go?");
scanf(%d%, &Y, &N);
And finally; If the user would like another go, then I am trying to include the code that clears the screen and then reloads the program?
What code is used to clear the screen and no clue what code is written to refresh or reload the program. I assume it's a loop statement or some sort.
View 1 Replies
View Related
May 21, 2013
here is a nested stl map
typedef struct struct_RISCP {
float nSCPTotal;
int nSCPCount;
CString strIMEI;
std::map<UINT8, int> mapSection;
}RISCPSt;
map<stRncCellIdntyDmnType, RISCPSt>m_mapRISCP;
it occupied too much memory,i wanted to clear them(both outer map and inner map) ,some one told me you just need to call m_mapRISCP.clear(),then the mapSection (inner map) will be cleared automaticly,in other words, m_mapRISCP.clear() will clear both outer map and inner map.
View 5 Replies
View Related
Apr 4, 2014
vector<int> *vec; allocate memory and
suppose vec conatins 10 values then
erase(vec->begin(),vec->end());
vec.clear();
both should be used or any one one is fine to erase all ??
View 1 Replies
View Related
Mar 26, 2014
I am trying to clear the first character of my array. The first two methods don't seem to work. The third method seems to but doesn't look like a good idea.
char operand[] = "abc";
//both methods seem to null it out
operand[0] = 0;
memset(operand, 0, 1);
printf("%s", operand);
//seems to work
memset(operand, 5, 1);
View 4 Replies
View Related
Jun 5, 2014
I need to clear a listbox from a class other than the form where it exists. Why this isn't working? I'm getting no error messages when I compile and I am seeing the Console.WriteLine text I also added in the same function. I can call this function from within my form and it behaves as expected. I tried setting the listbox to public despite the fact I wasn't getting protection level errors but that made no difference.
Just to clarify what I'm doing here... I have a form that includes a panel of user controls from another class. So there is a listbox on OtherClass and the listbox is in MyForm. Heres my code:
MyForm
public void ClearListBox() {
Console.WriteLine("echo");
listBox.Items.Clear();
} OtherClass
private void listBox_SelectedIndexChanged(object sender, EventArgs e) {
MyForm mf = new MyForm();
mf.ClearListBox();
}
View 9 Replies
View Related
Jul 28, 2013
I'm writing a program that converts hex to letters and writes the letters to a file.To write I'm currently using ofstream("output.txt" ios::app)But the issue with this is, is that everytime I run the program, it appends and doesn't write from the beginning of the text file.So what I want to know is, how do I clear the contents of a text file, before writing to it?
View 1 Replies
View Related
Feb 5, 2013
How to clear data from a char array?
View 19 Replies
View Related
Feb 12, 2015
When creating an exception mask for a file, should an exception throw during a file operation, I can reset the state bits of the actual file using ios::clear().
Though after doing so, will the exception mask still throw an exception, thinking that the specified error state flags are still set to true? If so, how can I reset the exception mask so that it is ready to throw more exceptions should the appropriate situations arise in the future?
View 2 Replies
View Related
Dec 15, 2012
Code:
std::ostringstream ss;
ss.flush();
ss.clear();
ss << v.x;
std::string buff(ss.str());
XMLString::transcode(buff.c_str(), tempStr, 99);
[Code] ....
The buff at "Z" are stringed together with previous values. How do I resolve that?
View 5 Replies
View Related
Dec 14, 2014
I have a college project which is a car racing game using C++ and the old-school graphics library BGI. After I draw the map and placed the objects(Car,obstacles,road's borders etc..)I added Sleep(); function to the function named Obstacles(); but the problem is, I can't move the car with the right&left arrows.a
Another problem,If I added a cleardevice(); command all objects disappears only the obstacles function keeps working. the Code is here:
char c;
do{
c = (char)getch();
if (c == KEY_LEFT) {
x = x - 10, x1 = x1 - 10;
} if (c == KEY_RIGHT) {
x = x + 10, x1 = x1 + 10;
[code].....
note: this is not the whole code, it's only a small portion of it, not a debugging question only need a hint how to fix it.
View 3 Replies
View Related
Dec 25, 2014
I have 2 datagridview in one windows form, When I click row from datagridview1, it shows in datagridview2 (Select *from....). Also I have combobox column in datagridview2. My question is, when I select items in combobox, and click to new row in datagridview 1, datagridview2 combobox's is getting empty. it is my code:
private void dataGridView1_CellDoubleClick_1(object sender, DataGridViewCellEventArgs e) {
try {
int id = Convert.ToInt32
(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["id"].Value);//3
[Code] .....
View 8 Replies
View Related
Mar 14, 2015
I've got myself a 2d array
int[,] map = new int[100,100];
I've populate that will a bunch of 1's and 0's. The 1 represents a wall, and a 0 is dirt.
I'm looking for a way to clean up my blank spaces outside of my walls. Any algorithm I can use to identify these big areas and replace them with a '1'
for (int y = 1; y < map.GetLength(1) - 1; y++) {
for (int x = 1; x < map.GetLength(0) - 1; x++) {
// Inside here is where I was hoping to archive my work
bool draw = true;
foreach (Room room in rooms)
[Code] ....
Attached is an example of my output.As you will be able to see, there is a lot of brown. I want to fill the brown with walls, but leave space for a path between the rooms.The 'draw' bool is true when I'm outside of a room, just so I don't start throwing walls inside my room.
Example of what the array would look like (for those who don't know)
int[,] map = new int[100,100]
{
{0,1,1,1,1,1,0},
{0,1,0,0,0,1,0},
{0,1,0,0,0,1,0},
{0,1,0,0,0,1,0},
{0,1,0,0,0,1,0},
{0,1,1,1,1,1,0},
};
View 6 Replies
View Related
Jul 4, 2013
Say I have a structure defined as such:
struct data{
char c;
int x;
};
And I want to create a function to print either c or x. However, I don't want to just use a switch or something to figure this out, I want to reference which part I'm outputting.
Now here's the twist
vector<data> dataList;
I need to access element x or c in the vector, but all I pass is the vector and which element, so that I might have something like:
void (vector<data> x, DataType i){
cout << x[0].i;
}
So now, if I pass either x or c (someway), I can output one of them.
View 19 Replies
View Related
Jul 1, 2014
for example i have
int count = t1;
while(count>counter){
Sleep(delay);
Int32::TryParse(textBox2->Text,add);
result = result + add;
counter = counter + 1;
Problem is that sleep stops all program for specified time, Is there an alternative to sleep that would only stop part of code or can i use sleep different way to specify what it pauses?
View 8 Replies
View Related
Dec 7, 2013
Is it valid for an object to return an object of they same type? GetBlock method
class memBlock {
private:
char *mem;
unsigned long length;
public:
memBlock(char *data,unsigned long startPoint, unsigned long endPoint) {
[Code] .....
View 1 Replies
View Related
Jan 20, 2015
I am having a little bit of trouble with what should be a simple part in my code. For some reason it keeps looping the name part of the program and I seem to be passing over the problem in the code.
Here is the code:
#include <iostream>
#include <string>
using namespace std;
[Code]....
View 6 Replies
View Related
Nov 26, 2012
I have the following string: "type computer {dell}"
And I want to remove the {dell}
So that the output on the screen type computer
Or delete any clause between the two brackets {}
How do i do that ?
View 5 Replies
View Related
Sep 29, 2014
Code:
// string::erase
#include <iostream>
#include <string>
int main () {
std::string str ("This is an example sentence.");
std::cout << str << '
';
str.erase (10,8);
std::cout << str << '
';
Code:
Output:
I don't understand this program. What do these 2 numbers represent? The index of an element in a character array? The 10th character of the array is 'n' and 8th is a "space".
View 14 Replies
View Related
Jan 2, 2014
I'm having a problem converting part of a string to an integer.I used strtok to seperate my string and I have also a function for atoi but how to apply it to my strtok function.What i need is to change the char *years to an int.Have a look of what I got:
Code:
int main() {
char sentence[]="trade_#_2009_#_invest_#_DEALING";
char *word=strtok(sentence, "_#_");
char *year=strtok(NULL, "_#_");; // assigning NULL for previousely where it left off
char *definition=strtok(NULL,"_#_");
char *synonyms=strtok(NULL,"_#_");
[code]...
View 2 Replies
View Related
Mar 30, 2014
I have a character array that includes configuration bits that are 0x00, thus when I try and do a strcat it adds the appended string into one of those spots instead of the end of the array.
View 2 Replies
View Related
Jun 12, 2014
I'm writting an algorithm which equals to std::to_string. The inttostring part is fine, and the decimal_part too. But when the number digits > 5, the program loops infinitely.
#include <iostream>
#include <string>
#include <algorithm>
[Code]...
In this code, the program runs ok. But try to add a 5 at decimal_part. What should I do to get this 'decimal_part' ok?
View 6 Replies
View Related