I'm not asking for code I'm asking for help. yes it is for a project for class.
Program reads a .txt file that contains something like this,
* NOT 10100110
* AND 00111101
Program needs to read the operator and perform a function according to that operator to alter the byte. Then output the altered byte.
What I know how to do:
* Open the file up.
* read from the file.
* I can store the byte in an array.
What I need help with:
* Reading the operator (AND, OR, NOT)
* Store each bit inside an array (I can store the byte but not the bit)
My code:
#include <iostream>
#include <fstream>
#include <istream>
#include <cctype>
#include <cstdlib>
#include <string>
using namespace std;
int main()
{
const int SIZE = 8;
int numbers[SIZE]; // C array? to hold our words we read in
int bit;
std::cout << "Read from a file!" << std::endl;
std::ifstream fin("small.txt");
for (int i = 0; (fin >> bit) && (i < SIZE); ++i)
{
cout << "The number is: " << bit << endl;
numbers[i] = bit;
}
fin.close();
return 0;
}