Advertisement
Guest User

Untitled

a guest
Aug 26th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. #include "pch.h" // for VS (must be first)
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main(int argc, char *argv[])
  7. {
  8.  
  9. ////// TASK 2, Convert negative integer.
  10. // // Write a small program that defines a negative integer(between - 1 and -255),
  11. // // converts it to a positive value and then displays it on the console window.
  12. //
  13. // int negativeNumber = -30;
  14. // int positiveNumber = abs(negativeNumber);
  15. // cout << positiveNumber << endl;
  16.  
  17.  
  18. ////// TASK 3, check argument is numerical
  19.  
  20. for (int x = 0; x < strlen(argv[1]); x++) {
  21. char ch = argv[1][x];
  22. if (!isdigit(ch)) {
  23. cout << "Error: non digit found in argument 1." << endl;
  24. break;
  25. }
  26. }
  27.  
  28. //for (portb = 0; portb <= 100; portb++)
  29. //{
  30. // _itoa_s(portb, val_string, 10);
  31. // strcpy_s(command, BaseWriteCommand); // reset the command array with the BaseWriteCommand string
  32. // strcat_s(command, val_string); // append the value to write to portb to the Command string
  33.  
  34. // // pipe code that sends out the current Command stored in the command variable
  35. // fpipe = (FILE*)_popen(command, "r");
  36. // if (fpipe != NULL)
  37. // {
  38. // while (fgets(line, sizeof(line), fpipe))
  39. // { //do nothing, or print out debug data
  40. // cout << "Debug line:" << line; // print out OUSB data
  41. // }
  42. // _pclose(fpipe);
  43. // }
  44. // else cout << "Error, problems with pipe!\n";
  45.  
  46. // cout << endl;
  47. // portb++;
  48. //}
  49.  
  50.  
  51.  
  52. // //// TASK 5, READ PINC
  53. //// Declare common variables
  54. // char command[255] = {}; // array that will hold the OUSB commands
  55. // char line[255] = {}; // array to hold received data from the OUSB board
  56. // FILE *fpipe; // file variable, see text book module 11.
  57. //
  58. // char ReadCommand[] = "ousb -r io PINC"; // String containing the OUSB read command
  59. //
  60. // strcpy_s(command, ReadCommand); // reset the command array with the BaseWriteCommand string
  61. //
  62. // // pipe code that sends out the current Command stored in the command variable
  63. // fpipe = (FILE*)_popen(command, "r");
  64. // if (fpipe != NULL)
  65. // {
  66. // while (fgets(line, sizeof(line), fpipe))
  67. // { //do nothing, or print out debug data
  68. // cout << line; // print out OUSB data
  69. // }
  70. // _pclose(fpipe);
  71. // }
  72. // else cout << "Error, problems with pipe!\n";
  73. //
  74. // cout << endl;
  75. //
  76. //
  77. // //// TASK 6, READ PINC AND APPEND
  78. //// Declare common variables
  79. // char command[255] = {}; // array that will hold the OUSB commands
  80. // char line[255] = {}; // array to hold received data from the OUSB board
  81. // FILE *fpipe; // file variable, see text book module 11.
  82. // int lineInt;
  83. //
  84. // char ReadCommand[] = "ousbsim2 -r io PINC"; // String containing the OUSB read command
  85. //
  86. // strcpy_s(command, ReadCommand); // reset the command array with the BaseWriteCommand string
  87. //
  88. // // pipe code that sends out the current Command stored in the command variable
  89. // fpipe = (FILE*)_popen(command, "r");
  90. // if (fpipe != NULL)
  91. // {
  92. // while (fgets(line, sizeof(line), fpipe))
  93. // { //do nothing, or print out debug data
  94. // // cout << line; // print out OUSB data
  95. // lineInt = (int)atoi(line);
  96. // }
  97. // _pclose(fpipe);
  98. // }
  99. // else cout << "Error, problems with pipe!\n";
  100. //
  101. // cout << lineInt + 12;
  102. //
  103. // cout << endl;
  104. //
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement