First of all id like to thank cprogramming.com and its member's for its fantastic tutorials and faq's as between you guy's and google you've taught me all i know about c/c++
ive been to writing a simple program to control a parallel port I/O card, but the time has come where i need a little help.
the code snip below is what im using to check the variable "input" against the input_address array, this works fine for checking 1 input line at a time but if 2 or more inputs are pulled high it dosent work.
let say input 1 and 2 are high the variable "input" will = 3
or if all 8 are high "input" will = 255
i need it to print out, inputs 1 and 2 are high or inputs 1, 2, 3, 4, 5, 6, 7 and 8 are high and whatever in between e.g.,
if the variable "input" == 82 then print inputs 2, 5 and 7 are high
and for my second question, in the line below how do i put these : every 2 digits to get the output to look like this 12:01:01 instead of 120101Code:int input_adress[10] = {0,1,2,4,8,16,32,64,128}; for (i = 1;i < 9;i++) { if (input == input_adress[i]) { cout << "Input " << i << " is HIGH" << endl; } else { input == 0; cout << "Input " << i << " in LOW" << endl; }}
Thank you for your very much time BudgieCode:cout << "The time is"<< setfill('0') << setw(6) << thetime << endl;



LinkBack URL
About LinkBacks


