C++ :: Making A Finite State Machine For Lab?

Apr 20, 2013

I am making a finite state machine for a lab. I have here a 2 files with the code for the FSM. I know it isn't finished yet, I know what needs to be put in. The only things I would need help on are the errors that I get.

Warrior.h
#ifndef _WARRIOR_
#define _WARRIOR_
#include "State.h"

[Code]....

View 1 Replies


ADVERTISEMENT

C/C++ :: Circular Buffer In The Form Of Finite State Machine

Dec 11, 2014

I'm supposed to create a circular buffer that reads an input file and outputs data after running though basically an integral equation. Everything my be referenced by pointers. When I build I am being told segmentation fault: 11. From what I have gathered that means there is a problem with my memory allocation correct? I'm including the custom header file and the main.c as well.

header file :

#ifndef FSM_H
#defineFSM_H
#define INPUT_BUFFER_LENGTH 2
#define OUTPUT_BUFFER_LENGTH 2
#define INITIAL_INPUT {0,0}
#define INITIAL_OUTPUT {0,0}

[Code] .....

View 1 Replies View Related

C++ :: Turning BMP Image To Min Finite Automata

May 14, 2013

I don't know how to start with it, first thing that came up to my mind was "loop through an array of bits" in bitmap (monochromatic), but I can't get the bits. Here's code I have:

#include <iostream>
#include <fstream>
using namespace std;
unsigned char* readBMP(char* filename) {

[Code] .....

No errors, it's working fine but I just can't get the bits of picture. I've tried to "cout" values form header (width, height) and they're ok, but I wonder how to get representation of picture itself. I thought that this code will give me something like array of 1 and 0.

I have to convert black and white (monochromatic) bmp image to min. finite automata.

View 12 Replies View Related

C++ :: Deterministic Finite Automata Implementation

Nov 13, 2013

Can implement a determinisitic finite automata by reading from a text file that looks like this:

q0 q1 q2 q3 (states)
a b (alphabets)
q0 (start state)
q0 q1 q2 (accept states)
f(q0,a)=q1 ( rest are transitions)
f(q0,b)=q1
f(q1,a)=q2
f(q1,b)=q2
f(q2,a)=q2
f(q2,b)=q2
f(q3,a)=q3
f(q3,b)=q3

View 1 Replies View Related

C++ :: Finite Difference Method For Partial Differential Equations?

Nov 10, 2013

Calculated by the explicit scheme. Produces some very large numbers.

task:

[math] U_t = 3 (1,1-0,5 x) U_ {xx} + e ^ t-1 [/ math]
[math] U (0, t) = 0 [/ math]
[math] U (1, t) = 0 [/ math]
[math] U (x, 0) = 0.01 (1-x) x [/ math]

Need to find a solution with accuracy [math] 0.0001 [/ math] on the interval [math] T = 1 / a ^ *, where a ^ * = max a (x, t) [/ math] Plot graphs of functions [math] u (x ^ *, t), u (x, jt ^ *) [/ math] where [math] x ^ * = 0.6, t ^ * = T/10, j = 1,2,4 [/ math]

explicit difference scheme is as follows:

([math] $ u_t ^ {j +1}-u_i ^ j) / tau = 3 (1,1-0,5 x_i) (u_ {i +1} ^ {j}-2u_i ^ j + u_ {i -1} ^ j) / h ^ 2 + e ^ {t_j} +1 $ $ [/ math]

code of the program:

int main ( void ) {
setlocale(LC_ALL, "rus");
int I = 10, J = 30, i, j;
double T = 1.0/ pow(3.3, 0.5), h_x = 1.0/ I, h_t = T/ J, epsilon = h_t + pow(h_x, 2), c;
double **u = new double *[I + 1];
for (i = 0; i <= I; i++) u[i] = new double [J + 1];

[code]....

displays the following:

[URL]

View 2 Replies View Related

C++ :: COM Exe Not Running On A Particular Machine?

Jul 23, 2012

I have a COM exe which runs fine on all machines that I have used except one. On a particular machine, the COM exe does not start even after trying to execute it manually (do a double click on the file from explorer).

There are no error messages as well. what could be happening ?

View 8 Replies View Related

C++ :: Design A Program For A Machine?

Jul 10, 2014

My need is that i need to design a program for a machine. The machine takes "x"qty of load, refines 30% of it and sends back the 70% to the initial position. after how many times, does the qty of the load refined will be equal to the initial load and how many times does it need tot be refined?

View 1 Replies View Related

C++ :: Compilation In Machine Language

Jan 25, 2013

Have a program which given a C source code file, gives back RAW MACHINE CODE, which means it doesn't have to be a executable on his own.

Like:

Given a example function for C:

int stdcall Function(void)
{
return 0;
}

Gives back the Machine Code for the Example Function.

It doesn't need to be actual C code, it can also be like:

type int
return 0

Or also it can be a straight assembly-to-machine-code compiler.

Is there any Library? Or even a external tool I can look into?

View 4 Replies View Related

C++ :: Chocolate Vending Machine

Sep 25, 2013

My group's chocolate vending machine code is clean, but has a problem.

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
using namespace std;
int main() {
// Variables from function "chocoSelect".

[Code] ....

The functions doesn't seem to link in proper. Also, for the "chocoSelect" function, if a user enters a selection number other than 1 to 5, the machine will stall and wait for 10 seconds to try again. How?

View 11 Replies View Related

C++ :: Empty State Of Queue?

Feb 18, 2013

what is the empty state of queue?

View 5 Replies View Related

C/C++ :: Linux Console Get Key State

Jan 23, 2014

I want to create command line game in Linux but I don't know to get the key state. I heard of getch() but that stops the program.

View 1 Replies View Related

C++ :: State Of Variable In One Expression

Mar 27, 2014

I thought that an operator performs a permanent change in a local variable. For example, if x is 00000000 00000000 00000000 00000011 (a 32 bit unsigned integer that resolves to value of 3) and p is 2, in the expression "return (x >> p) | (x << (s - p))", the right shift would permanently change x to 0 and the time we evaluate x again in "(x << (s - p))", x will already be 0. If that's the case, then this function doesn't make sense. This function makes it seem like that the >> and << operators do not change the value of x. It makes it seem like first we right shift x to 0 and then left shift by 20 bits to make x 11000000 00000000 00000000 00000000. If that's the case, then the function does exactly what it is supposed to do (rotate the bits). So which is it?

unsigned int rightrot(unsigned int x, unsigned int n) {
size_t s = sizeof(x) * CHAR_BIT;
size_t p;
if(n < s)
p = n;

[Code] ....

View 2 Replies View Related

C++ :: Simulate Adding Machine - Total / Subtotal

Mar 28, 2013

Write a program that simulates an adding machine. When a zero is entered it should print the subtotal of all the numbers entered from the last zero that was entered and reset the subtotal. When two consecutive zeroes are entered it should print the total (not the subtotal) of all the numbers entered and terminate the program. Example:

1
2
3
0
subtotal 6
4
5
-2
0
subtotal 7
8
0
subtotal 8
0
total 21

Be careful this program needs a bit more thought than you might think at first. To get full credit you must make sure it also works for the 0 - 0 case. Example:

0
subtotal 0
0
total 0

The problem is, after I enter the integers and type 0, it shows the subtotal which is what I want; however, when I type more integers and type another 0 to see the subtotal again, it shows the total instead. The subtotal should reset whenever a single 0 is typed and the total should only show when two 0's are inputted simultaneously. Also, after the user enters two 0's simultaneously and views their total, I want the program to exit by saying "press any key to exit." Is there a special name for that to happen? Here is my code:

#include "stdafx.h"
#include <iostream>
using namespace std;
int main() {
int subtotal = 0, total = 0, number = 0;
bool input_zero = false;

[Code] ....

View 2 Replies View Related

C++ :: Vending Machine - Expected Primary Expression Before Else

Apr 23, 2014

This is my code so far and in my else if statements its sayin "Expected Primary Expression Before "Else"

What do i do?

#include <iostream>
using namespace std;
int main () {
//declare variable
double n,a,b,c,d,total;

[Code] ....

View 3 Replies View Related

C/C++ :: ATM Machine - Get Amount Balance Into Other Functions From File

Oct 25, 2014

I have part of it done but im not sure how to get my amount balance to get into my other functions from my file...

#include<iostream>
#include<fstream>
using namespace std;
void welcomeUser();
bool readFile();
void menu();

[Code] ....

and the amount saved that I have in the file is 1200

View 14 Replies View Related

Visual C++ :: How To Extract Machine / Hardware ID And OS Version

Nov 19, 2014

Is there a way I can extract Machine / Hardware ID and OS Version using VC++?

View 3 Replies View Related

C++ :: Changing State Names To Abbreviations?

Feb 13, 2014

The purpose of the code is to read in state names, say california and print CA. However, if it was a state with two words, it would read in only the first letter of each. I.E New Hampshire would be NH.

here's my code:
#include <iostream>
#include <iomanip>
#include <cctype>

[Code].....

I am able to get the one word states and tried getting the two word states but it doesnt work.

View 1 Replies View Related

C/C++ :: Reverse A String And State If It Is A Palindrome

Mar 28, 2015

I am supposed to take the three string lines from a text file and then individually reverse them and state whether or not they are a palindrome. I have the three lines from the text file into string variables already but I am not sure on how to reverse them and then see if they are the same reversed(palindrome)

Here is my code so far -->

#include <iostream>
#include <string>
#include <cctype>

[Code].....

EDIT: Ignore line 123 and down in the code. That was merely test code and will not be used.

View 7 Replies View Related

C# :: Bingo Calling Machine / Changing Numbers To Different Text Boxes?

Dec 28, 2014

I've recently started creating a bingo caller application. I need in changing numbers to different text boxes. When a number is called it will be displayed in a text box and the last four numbers previous to that. However the oldest number needs to delete and for the remening numbers to move when a new number is called.

View 2 Replies View Related

C Sharp :: Store Values In Variable Permanently Even After Restarting Machine?

Dec 26, 2013

I want to store values permanently in a variable. The same variable should be able to be edited and saved by user, and whatever it is I need the value of the variable from the last time I modified it, like a database. database because i need this to set my connection string of the database.

View 1 Replies View Related

C++ :: State The Values Of Each Int Variables After Calculation Is Performed

May 2, 2013

Question: State the values of each of these int variables after the calculation is performed. Assumed that, when each statement begins executing, all variables have the integer value 5.

a) product *= x++;

b) quotient /= ++x;

What is the answer for a and b?

View 4 Replies View Related

Visual C++ :: Debugging - Revisiting Same Memory State?

Oct 31, 2013

When running my code in Visual Studio, there is a particular point in the code where my program is crashing. To debug this, I am adding a break point in Debug mode just before that point, and observing what happens as I step through the code. However, to get to this break point in the code takes about a minute of running the program. So I'm wondering if there is a tool in Visual Studio to reload the state of a program's memory from a previous run, so that I can immediately get to the break point without having to wait for a minute each time?

View 6 Replies View Related

C++ ::  Initializing Boost Asio Variables In State Program

May 5, 2014

I am trying to initialize this chunk of code without it starting at the main menu in my state program:

boost::asio::io_service io_service;
tcp::resolver resolver(io_service);
tcp::resolver::query query(argv[1], argv[2]);
tcp::resolver::iterator iterator = resolver.resolve(query);
chat_client c(io_service, iterator);
boost::thread t(boost::bind(&boost::asio::io_service::run, &io_service));
char line[chat_message::max_body_length + 1];

This code came from a example at the boost example list: URL.....I want the networking to start when the multiplayer state initializes. This is how my program basically looks like:

//Main.cpp
main() {
if (!quit) {
while( handleing_events ) {
CurrentState->handleEvents();

[code].....

I tried to put the stuff in extern at states.h, and initialize it at Multiplayer(), but in handleEvents & ~Multiplayer, it says "c" is not defined...

View 8 Replies View Related

C++ :: State Design Pattern - Calling A Class Member

Oct 17, 2013

In the following code example of the State Design Pattern, in the main code at the bottom it defines an instance of class Machine, and then calls Machine::off;. Why doesn't it instead call fsm.off;?

Machine fsm;

Machine::off;

Then I tried imitating that by adding a class Abba, and then doing:

Abba a;
Abba::DoStuff();

but that didn't work. Why?

Full code example:

// StatePattern.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
using namespace std;
class Machine {
class State *current;

[Code] ....

View 3 Replies View Related

C++ :: Concatenation Of Strings When Entering City / State And Zip Code

Apr 15, 2013

I have written my code, but can't seem to figure out why it doesn't enter the while loop and start asking for Input.

Code:
#include <iostream>
#include <string>
using namespace std;
int main(){
//declare variables
string cityName = "";
string stateName = "";

[Code] ....

View 3 Replies View Related

C :: Program To State User Chinese Zodiac And Horoscope Sign After Inputting Birthday

Mar 26, 2013

I am a beginner trying to write a program that would state a user's chinese zodiac and horoscope sign after inputing his or her birthday. I have been, however, having trouble getting the program to run correctly.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

#define CAPRICORN "G"
#define AQUARIUS "W"
#define PISCES "F"

[Code] ......

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved