473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

File Input/Output

Okay, I want to allow the user to define their own variables and
equations and then use them to run a program. The user picks the
option to create a list of variables
If the user enters in r d and s at the prompt
how would you define each as a double variable?

Secondly I want to allow the user to enter in an equation that would
stored in a file than spit out when the program is running to
calculate the values. Let's say the user put

r+d+s
I was thinking of opening up a filestream and reading the user entered
equation into a file as a string

cin >equation

fileout << equation
then reading it back into the string variable once the user chooses
the option to calculate values.

filein >equation

and using the variables and the equation to calculate x.

x = equation

But I think it will give me errors since x just might spit out the
string. Can someone help me figure out a way to get this to work?

Thanks

Jul 24 '07 #1
5 1552
nk****@gmail.com wrote:
Okay, I want to allow the user to define their own variables and
equations and then use them to run a program. The user picks the
option to create a list of variables
[..]
Programming an interpreter has been covered in literature for quite
some time now. Please google for "C++ expression interpreter".

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jul 24 '07 #2
On Jul 24, 2:21 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
nko...@gmail.com wrote:
Okay, I want to allow the user to define their own variables and
equations and then use them to run a program. The user picks the
option to create a list of variables
[..]

Programming an interpreter has been covered in literature for quite
some time now. Please google for "C++ expression interpreter".

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask

Actually, I only get mostly this and related comments back with
google. I only want to parse equations and numerical values so
hopefully it won't be too complicated

Jul 31 '07 #3
nk****@gmail.com wrote:
On Jul 24, 2:21 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
>nko...@gmail.com wrote:
>>Okay, I want to allow the user to define their own variables and
equations and then use them to run a program. The user picks the
option to create a list of variables
[..]

Programming an interpreter has been covered in literature for quite
some time now. Please google for "C++ expression interpreter".

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


Actually, I only get mostly this and related comments back with
google. I only want to parse equations and numerical values so
hopefully it won't be too complicated
Get a hold of a copy of TC++PL by Stroustrup and open chapter 6
("Expressions"). It contains an example of expression interpreter
you could model/extend on.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jul 31 '07 #4
Victor Bazarov wrote:
nk****@gmail.com wrote:
>On Jul 24, 2:21 pm, "Victor Bazarov" <v.Abaza...@comAcast.netwrote:
>>nko...@gmail.com wrote:
Okay, I want to allow the user to define their own variables and
equations and then use them to run a program. The user picks the
option to create a list of variables
[..]
Programming an interpreter has been covered in literature for quite
some time now. Please google for "C++ expression interpreter".

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask

Actually, I only get mostly this and related comments back with
google. I only want to parse equations and numerical values so
hopefully it won't be too complicated

Get a hold of a copy of TC++PL by Stroustrup and open chapter 6
("Expressions"). It contains an example of expression interpreter
you could model/extend on.

V
Get c-snips from
http://www.cs.umu.se/~isak/snippets/
They have code for eval.c a simple command line calculator.
Also a ton of other small, usefull c cource.
Enjoy.
Jul 31 '07 #5
In article <46***********************@text.nova.planet.nl>,
bu*************@ppllaanneett.nnlll says...

[ ... ]
Get c-snips from
http://www.cs.umu.se/~isak/snippets/
They have code for eval.c a simple command line calculator.
Also a ton of other small, usefull c cource.
Just FWIW, the home of this collection is www.snippets.org.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Aug 5 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: suresh | last post by:
Hello All, Iam writing a wsdl file using the Servicedescription class.The document I get is a well formed xml document.But some how when I try to add this wsdl file as a webrefernce to another...
1
by: moonriver | last post by:
In a xml file, can we make reference to another xml file so that all contents of the latter xml file will be included into the first xml file? Had better give me an example for details.
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
4
by: pank7 | last post by:
hi everyone, I have a program here to test the file IO(actually output) with buffer turned on and off. What I want to see is that there will be obvious differece in time. Here I have an input...
6
by: neo | last post by:
Hello everyone, I want to write a function that takes a simple text file as input and outputs a file such that the last line in the input file becomes the first line in the output file and the...
1
by: Osoccer | last post by:
...to a different folder and in the relocated file concatenates all of the lines in one long string with a space between each line element. Here is a fuller statement of the problem: I need a...
24
by: allpervasive | last post by:
hi all, this is reddy, a beginner to c lang,,here i have some problems in reading and modifying the contents of a file,, hope you can help to solve this problem. Here i attach the file to be...
0
by: jebbyleezer | last post by:
Hello, I have source code that builds correctly, however, after the program terminates the output file produced is empty. Here is my source code: import java.io.*; import java.util.Scanner;...
0
by: Craftkiller | last post by:
=========Program compiles on both windows and linux=========== Greetings, I am currently working on an encrpytion program that will take a file and a password string and flip the bits based on the...
4
by: rsaharia | last post by:
Hello All, I need help with this particular .pl file I picked up from http://www.veritools-usa.com/xnf2vhdl.htm What it's supposed to do is really convert an xnf file to a vhdl file. I need it for...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.