hello friends!
how do i read this line:
calc <op1> <op> <op2>
I need op,op1,op2 in a function.
I hope the example helps u.
ex: calc 40 / 8
output: 40/8=5
Tks!
hello friends!
how do i read this line:
calc <op1> <op> <op2>
I need op,op1,op2 in a function.
I hope the example helps u.
ex: calc 40 / 8
output: 40/8=5
Tks!
Last edited by atemlos; 05-19-2003 at 07:46 AM.
try it.
How do you read it?????
calc is the name of the function
op1 and op2 are the operands (the numbers)
and op is the operator (+, -, *, /, etc)
So write a function that takes those 3 parameters, and returns a value in the appropriate data type (int, double, etc).
(Is that what you're asking?)
He means that his program reads that line from user input and solves it.
alright man, if you have apstring (if you dont have it download it from anywhere)
apstring has this function called find(character)
apstring also has a function called substr (int starpos, int howmanyspaces)
apstring uses classes so lets say you do this
NOT ACTUALY CODE
first declare it
apstring input, temp;
int ptr; //points to the pos of found character
ptr=input.find(" "); //find a space
temp=input.substr(0,ptr); //temp will now be the first number
Then see wat temp is then change the space to a "*" so you dont find it again.
input[ptr]="*";
next just find the next space and find the substring text etc.
i hope you get it
read: i have 4 strings and whit a space between them, but the 2. and the 4. are integers. ho do i make int from the strings.
Look up atoi function. This will convert a c-style string (char array) to an integer.
It's in <stdlib.h>, or <cstdlib>.
I just looked at your code in the other thread.
First lesson:
Don't make multiple threads for the same issue.
Second:
You are NOT reading the user input into your strings. I don't have much time to go into it now -- have to go take an exam -- but one way is, instead ofyou could useCode:char d[4];then, afterCode:char a[4]; char b[4]; char c[4]; char d[4];
you could put a few of these:Code:printf("type line:\n");
Then you'll have 4 separate strings -- easy to work with.Code:cin << a; etc...
most semi-cool programs enter it in 1 line =D
Probably better to have a goofy program that works than a semi-cool one that doesn't.