errorchecking: while (file >> i)
{
if (i < 0 || i>15)
{
cout << "Y" << endl;
goto errorchecking;
}
/*FILE *fpipe;
char line[256] = {};
fpipe = (FILE*)_popen(command, "r"); // attempt to open pipe and execute a command
if (fpipe != NULL) // check that the pipe opened correctly
{
while (fgets(line, sizeof(line), fpipe))
{ // do nothing here, or print out debug data
cout << line; // print out OUSB data for debug purposes
}
_pclose(fpipe); // close pipe
}*/
FILE *fpipe;
stringstream myStringStream; // Very useful for converting different data types (helpful for string concatenation here)
string myString;
int myValue = i; // Value to write to PORTB
myStringStream.str(""); // Clear if used before.
myStringStream << myValue;
myString = "ousb -r io PORTB " + myStringStream.str();
if (!(fpipe = (FILE*)_popen(myString.c_str(), "r")))
{ // error if fpipe returns NULL
cout << "Problems with pipe" << endl;
exit(1);
}
while (fgets(line, sizeof(line), fpipe))
{
cout << line;
}