I have this code, it seems to be in c++. It came across my desk off a communication system and I want to make sure it is not anything important in operations.
I was hoping to run it, but i don't even know where to begin.
At this point I am trying to figure out what it is doing at each step, process, etc.
I am an electrical engineer in Canada but with no software background what so ever. Anyone can help. Even running it would be assume. Not sure where to start, go :(
I will show the code below,
Question 1: It open a file --> c:\\test.txt <-- is this something every operating system has in its hard drive, a test txt file?
Question 2: What is it doing? I am lost, thank you for any assistance in advance
---------------------------------------------------------------------------------------------------------------
#include "stdafx.h"
#include <fstream>
#include <iostream>
using namespace std;
class flipflop{
bool Q, data_in, feedback_active, aux_in;
public:
flipfop(int output, int fb){Q=(output>0)?true:false;feedback_active=(fb>0)?true:false;);
flipflop(){Q=false;feedback_Active=false};
void input(int d, int ad){data_in=(d>0)?true:false;aux_in=(ad>0)?true:false;};
int output(){return Q?1:0;};
void evaulate(){Q=(!feedback_Active)?data_in:(data_in^aux_in);};
};
int _tmain(int argc, _TCHAR* argv[])
{
int mask,i,d;
ifstream in_file;
char one_byte;
in_file.open("c://test.txt,ios::binary);
flipflop Z0(0,1);
flipflop Z1(0,1);
flipflop Z2;
while(in_file.read(&one_byte,(int)1)){
for(i=7;i>=0;i--){
mask=0x01<<i;
d=((unsigned int)one_byte&mask)?1:0;
Z0.input(d,Z2.output());
Z1.input(Z0.output(),Z2.output());
Z2.input(Z1.output(),Z2.output());
Z0.evaluate();
Z1.evaluate();
Z2.evaluate();
}
}
cout<<"FINAL RESULT\n";
cout<<"\t"<<"\t"<<Z0.output() <<" " << Z1.output() << " " << Z2.output() << "\n";
return 0;
}
----------------------------------------------------------------------------------