erasing a line...

closed account (zT7X92yv)
I am trying to erase a number before "Magic Date", how do I do that?

how come it doesn't work for "not Magic Date".


#include <cstdlib>
#include <iostream>

using namespace std;

int main()
{
int total, month, day, year;
cout << "Enter month: ";
cin >> month;
cout << "Enter day: ";
cin >> day;
cout << "Enter a two digit year: ";
cin >> year;
cin.ignore(2);

total = month * day;

if (total == year)
{

cout <<year << "magic year!"<<endl;

}
else
{
cout << "\nnot a magic year!"<<endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}

thanks!!!
[code] "Please use code tags" [/code]
I am trying to erase a number before "Magic Date", how do I do that?

how come it doesn't work for "not Magic Date".
I don't understand. ¿what were you expecting and what does it give you?
you can't erase it (the year), you can just initialized it to 0 (zero)
closed account (zT7X92yv)
sorry for being unclear.

This is my output...

Enter month: 1
Enter date: 12
enter year: 12

12magic date!
press any key...


"12magic date!"

I am expecting "magic date!"

thank you!
Last edited on
On the line you output "magic date!", just don't output the year anymore.
because you have cout <<year << "magic year!"<<endl;, which outputs the year variable first and then the nameless "magic year" string. just take out the year variable in the cout statement.

like this;
cout "magic year!"<<endl;

closed account (zT7X92yv)
Cheers!

thank you.
Topic archived. No new replies allowed.