C++ question

Hy i'm a beginner in c++ and this question may sound silly but i have a problem.
My cursor is yellow and every time i type a character the nextone is deleted automatically and so on. i think it's an option enabled but i can't find it; can someone tell me what to do?
hit insert
http://en.wikipedia.org/wiki/Insert_key
PROTIP: learn how to use your computer, then learn how to program.
damn i know this from wordpad but i didn't occured to me; i was thinking about something more tricky; thanks
SInce that really didn't count as a C++ type question I can add this to the discussion.
I am having an incrementation problem in this code. It is supposed to increment the hour and for each hour supply the distance traveled. As it stands it just displays the hours and the total distance traveled. Yes it's homework and no I wouldn't want anyone to write it but a small hint on why it won't increment and a swift kick in the ... right direction would be appreciated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include<iostream>
using namespace std;
int main()
{
	int speed = 0, distance, time = 1;	//declare variables

	cout <<"How fast will the vehicle be traveling? " << endl; //ask for user input
	cin >> speed;					//user input
	cout << "How long will it travel? " << endl;		//ask for user input
	cin >> time;					// user input
	distance = speed * time;				//formula
		if (speed < 0 || time < 1)	//cannot accept a negative value for speed or any value less than 1 for time travelled
{
cout << "Please re-enter your data! The value you have chosen is not valid. "<< endl; 
//ask user to re-enter input
}
else (time >= 1 && speed >= 0);// do not know if this works or is necessary as it seems to have no affect on output
{
	cout << "Hours " <<  "\t\t" << "Distance Traveled "  << endl; //headings for output
	cout << time++ << "\t\t" << distance++ << endl;	//supposed to increment output but it doesnt
}
[code]
return 0;
}[/code]
You are using post-increment, so time and distance is only incremented *after* the line is executed. (i.e. after you print out the variables)

Make a new topic next time please.
Last edited on
Sorry. I'll remember that when I post again.

So my call should occur before the else? Could I change the else to an if and put that code before the warning? It would the compile it first and "read" the time++ before the warning statement. Otherwise I'm not sure where it should go.
You have several options:

1) Just use variable+1 if you don't actually need to modify the data
2) Use a pre-increment
3) Use a post-increment, but put it before the cout, (basically simulating a pre-increment)
Topic archived. No new replies allowed.