Hello, Would someone be willing to take a look at this segment of code? I am trying to figure out how this segment of code operates. I can see how the program can evaluate a simple prefix statement like + 7 6. I cannot see how the program can solve a statement like + + 7 6 + 5 4. I've inserted some print statements in order to see what the program is doing and it is showing a = 7, b = 6, a = 13, a = 5, b = 4, b = 9, (22 = total). I …

Member Avatar
Member Avatar
+0 forum 3

For this assignment due **3/4/2013**, I have to write a program to read in and evaluate a post fixed expression. I also have to print out the expression read in followed by the results of the evaluated expression (while handling the add, subtract, and multiply operators) and handle multi digit numbers. The expressions I'm using are in the textle is PostFix.txt, which I've attached to this article so you can look at it The thing is that I can't use stacks in my code. Instead I have to use functions to act the same way as stack member functions. I …

Member Avatar
Member Avatar
+0 forum 4

So the program makes an inventory from a cvs file. The cvs file consists of dvds and books. here is the code: #include "StdAfx.h" #define _CRTDBG_MAP_ALLOC //for memory checking #include <iostream> #include <stdlib.h> #include <crtdbg.h> #include <iomanip> #include <fstream> #include <string.h> #pragma warning(disable: 4996 4018) using namespace std; #define COPYSTR(TARGET, SOURCE) \ TARGET = new char [strlen(SOURCE)+1]; \ strcpy(TARGET, SOURCE) ////////////////////////////////////////////////////////////////////-->ERROR class error { fstream error_file; void open_file(); void close_file(); public: error() {open_file();} ~error() {close_file();} void print_file(); void clear_file(); void add_file(int, const char*); }; void error::open_file() { error_file.open("error_file.txt", ios::in | ios::out | ios::app); } void error::print_file() { cout << "\nERRORS:\n"; …

Member Avatar
Member Avatar
+0 forum 8

Hey all! I was thinking about how to make a program, in which you write some c++ code and program tests that code with given examples. For example you input following code in that program: [CODE]#include <iostream> using namespace std; int main() { int a, b; cin >> a >> b; cout << a + b; return 0; } [/CODE] the program compiles and tests the code (for example it tests if you input 1 and 3, will 4 be written in console using that code) and gives you information if the program is working or not. Or in other …

Member Avatar
Member Avatar
+0 forum 2

In my code they're instructed to enter a width and height. However obviously these will be intergers, but I need to perform checks that they are intergers before they're used. Atm I've got this: [CODE] while True: if width.isdigit() == True and height.isdigit() == True: if width >= 2 and width <= 8: if height >= 2 and height <= 8: break else: width, height = eval(input("Enter the width and height of patches: (e.g. 6, 3) ")) else: width, height = eval(input("Enter the width and height of patches: (e.g. 6, 3) ")) else: print("You have entered word(s) rather than numbers")[/CODE] …

Member Avatar
Member Avatar
+0 forum 11

So basically I need to find a way to evaluate an infix that's been converted into a postfix. The code below takes an entered infix and converts it into a postfix but I don't know how to take that postfix and evaluate it. Every single tutorial I've seen evaluates a postfix entered directly instead of a infix, so I have no clue what to do. So i decided to ask for help in doing this. Though to be honest, I'm more interested in reading material then direct code so I can understand it. But if you explain the code, that'd …

Member Avatar
Member Avatar
+0 forum 10

I did some code to refresh my C. So many things have happened since 1987, but at least I started with ANSI instead of K&R. As I used the language so little, I think it is time to do some practise and even to learn some C++ to support my Python coding. See my code and tell, where I am doing stupid things. This is half copy of one other thread's code, but as I did not understand/trust the linked list part, I simplified it to simple array based fixed memory allocation version to practice structs and file IO. %s …

Member Avatar
Member Avatar
+0 forum 13

The End.