Solved

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

Posted on 1997-06-03
1
314 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
1 Comment
 
LVL 4

Accepted Solution

by:
jos010697 earned 100 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

  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 …
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

746 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now