Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

g++ UNIX:  cin.get()   and  accessint day info

Posted on 1997-06-03
1
Medium Priority
?
361 Views
Last Modified: 2006-11-17
> Could anyone email me help on using cin.get() on a unix system w/ g++?

> cin.get() seems to still wait for a return character.  I would like to
> just grab one char (similar to how PINE needs only one control char to
> proceed).

> Our current project also requires the day-of-the-week.
> For example, If the user inputs "02/14/99" I need to know that that day
> is a Sunday.  I have thought of computing the information, but was
> wondering if I can access the system (UNIX) within a c++ program to tell
> me the day-of-week.

> Help is greatly appreciated.
> Please reply via email.                             -Brett
0
Comment
Question by:flood
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 4

Accepted Solution

by:
jos010697 earned 300 total points
ID: 1163803
The way stdin is buffered is beyond the scope of control
of a C++ program, all you can do is set the terminal
driver to the appropriate mode. If you do something
like:

   system("stty raw");

begore calling cin.get(), your terminal will be set to a
non-canonical mode, i.e. no buffering is performed whatsoever.
After all reading is done, reset your terminal to cooked mode
again by calling:

   system("stty sane");

Note that this is a quick hack, there are faster (and better)
ways of doing this. Check your man pages for ioctl(),
termio() etc.

About the date stuff, check your man pages for mktime(),
gmtime() etc. They'll help you out ...

kind regards,

Jos aka jos@and.nl

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question