?
Solved

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

Posted on 1997-06-03
1
Medium Priority
?
350 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

Technology Partners: 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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

770 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