cin.get trouble

I need a better way of getting input from the user.

Page 1 of 1

7 Replies - 1755 Views - Last Post: 12 October 2001 - 12:33 PM Rate Topic: -----

#1 DestroyerOfWorlds  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 55
  • Joined: 11-October 01

cin.get trouble

Posted 11 October 2001 - 08:29 PM

I'm having trouble asking for the date from a user.

this is the code i'm using
       

char date[16]; // char array of 16 spaces

cout << "Please enter the date." << endl << "in "month DD, YYYY" format." << endl << endl; // directions cin.get(date, 16); // ?? cout << date; // used to see if it worked cin.ignore(80, ' ');

It doesn't allow me to even input anything it just skips and goes on the next block of code. i want to get input with spaces too.


Is This A Good Question/Topic? 0
  • +

Replies To: cin.get trouble

#2 supersloth  Icon User is offline

  • serial frotteur - RUDEST MEMBER ON D.I.C.
  • member icon


Reputation: 4503
  • View blog
  • Posts: 28,409
  • Joined: 21-March 01

Re: cin.get trouble

Posted 11 October 2001 - 08:43 PM

put your cin.ignore, before your cout, that lets the computer know that its done accepting, so then, it should work to print out.
Was This Post Helpful? 0
  • +
  • -

#3 DestroyerOfWorlds  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 55
  • Joined: 11-October 01

Re: cin.get trouble

Posted 11 October 2001 - 10:07 PM

Somehow i don't think that will help my problem.  It doesn't even prompt me to enter text... it just skip right throught it. Like what was happinging with XvJasonvX. (sorry if the name is wrong)

(Edited by DestroyerOfWorlds at 11:10 pm on Oct. 11, 2001)

(Edited by DestroyerOfWorlds at 11:14 pm on Oct. 11, 2001)

Was This Post Helpful? 0
  • +
  • -

#4 VxJasonxV  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 201
  • Joined: 03-October 01

Re: cin.get trouble

Posted 11 October 2001 - 10:55 PM

Your problem is almost the same...mine does something, yours doesn't do anything.
Let's see...it is weird that you never have a point to input your data...but I would go ahead and do what sloth suggested.

instead of:

cin.get(date, 16); // ??
cout << date; // used to see if it worked
cin.ignore(80, '
');

Just change it to:
cin.get(date, 16); // ??
cin.ignore(80, '
');
cout << date; // used to see if it worked

(Edited by VxJasonxV at 11:55 pm on Oct. 11, 2001)

Was This Post Helpful? 0
  • +
  • -

#5 DestroyerOfWorlds  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 55
  • Joined: 11-October 01

Re: cin.get trouble

Posted 11 October 2001 - 11:43 PM

Thats alot jason.. thats the same thing sloth told me... just with code...
Was This Post Helpful? 0
  • +
  • -

#6 runtime error  Icon User is offline

  • Lucky.Code
  • member icon

Reputation: 3
  • View blog
  • Posts: 629
  • Joined: 19-March 01

Re: cin.get trouble

Posted 12 October 2001 - 08:31 AM

hmmmm the code seems to work on my compiler. I am using VC++.

Have you tried what they suggested???

There might be something before hand. There maybe a
cin.get() with out a cin.ignore().

Was This Post Helpful? 0
  • +
  • -

#7 supersloth  Icon User is offline

  • serial frotteur - RUDEST MEMBER ON D.I.C.
  • member icon


Reputation: 4503
  • View blog
  • Posts: 28,409
  • Joined: 21-March 01

Re: cin.get trouble

Posted 12 October 2001 - 08:54 AM

i dont remember, if cin.get requires any extra header files, but i would make sure that you have all the ones that you should too. and always check the obvious, like maybe, since its not prompting, you may want to make sure your calling it in the first place, sometimes the most obvious things are what the code is missing, i know its happened to me..
Was This Post Helpful? 0
  • +
  • -

#8 DestroyerOfWorlds  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 55
  • Joined: 11-October 01

Re: cin.get trouble

Posted 12 October 2001 - 12:33 PM

Quote

Quote: from runtime error on 9:31 am on Oct. 12, 2001There might be something before hand. There maybe a
cin.get() with out a cin.ignore().

That was thanx Runtime.

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1