Previous in Forum: Saving Data in MsFlexgrid (VB6)   Next in Forum: MathCad Loop Problem - Returning All Values
Close
Close
Close
3 comments
Rate Comments: Nested
Commentator

Join Date: Sep 2009
Posts: 99

Software Operation

10/27/2010 11:03 AM

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;

}

----------------------------------------------------------------------------------

Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.
Anonymous Poster
#1

Re: Software Operation

10/27/2010 11:29 AM

You opened a C Language source file using a text editor.

You cannot run source code. You must compile the source code, link it, and then run the exe file that you created.

Most desktop Windoze computers do not have a compiler installed. You would needto install one.

Register to Reply
Guru

Join Date: Oct 2008
Posts: 42355
Good Answers: 1693
#2

Re: Software Operation

10/28/2010 9:29 PM

OMG!!

That's the launch code for 5 Scud's aimed at Crawford, Texas.

Don't play around with that. You could significantly increase the IQ of local residents if you launch!!...........

Register to Reply Off Topic (Score 5)
Guru
Engineering Fields - Instrumentation Engineering - New Member

Join Date: Dec 2009
Location: San Antonio, TX USA
Posts: 844
Good Answers: 29
#3
In reply to #2

Re: Software Operation

10/29/2010 12:29 PM

Are them nucular scuds?

__________________
"Do not worry about your difficulties in Mathematics. I can assure you mine are still greater". - Albert Einstein
Register to Reply Off Topic (Score 5)
Register to Reply 3 comments
Copy to Clipboard

Users who posted comments:

Anonymous Poster (1); lyn (1); RDGRNR (1)

Previous in Forum: Saving Data in MsFlexgrid (VB6)   Next in Forum: MathCad Loop Problem - Returning All Values

Advertisement