Here is my situation: I wrote a quick and dirty program to scan serial numbers off of a large number of items and store the data into a file. Unfortunately the real world process goes: scan, hit enter, scan again.
My question is can I get it to where I can avoid hitting enter repeatedly.
Sample input:
123YLR12
Here is my code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int i=0;
string death;//was showing a third party that anything can be declared a variable.
int main()
{
ofstream filevariable;
filevariable.open ("SavedDataFile", ofstream::app);
while (i==0) //infinite loop but it's fine i kill it with CTRL+C
{
cin>>death;
cout<<endl;
filevariable << death << endl;
}
}
Since it's not a single character but a series of letters and numbers pulled off a scanner i can't use _getch()
and I can't seem to find any sort of reference to how to avoid pressing enter.
Platform:
Ubuntu 14.04 32-bit.