c++

if (argc >= 3)
{
cout << "P" << endl;
return 0;
}

if (argc == 2)
{

ifstream file(argv[1]);
if (!file)
{

cout << "F" << endl;
return 0;
}

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;
}

_pclose(fpipe);

}
file.close();
}
I don't see a question here.
Please put you code part in code block so it more readable.:)

1
2
[code]
  // Your code // 

[/code]
Last edited on
Topic archived. No new replies allowed.