c++ evaluating string expression with variables [closed] - c++

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I want to do evaluate for example something like:
int x=10, y=2;
x=eval('x+(y*10)');

i can give you the code which i made, but would like you to try yourself. Here are the steps :
replace all the unknowns with their values
convert the expression to postfix
try to evaluate postfix expression using stacks

Related

Clang-Tidy: check number of lines in a function [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Can you please help me with how to check CPP files in a project for functions exceeding 'n' number of lines using Clang-Tidy?
You can use the readability-function-size check and set the LineThreshold parameter to your n value.

CPP intresting thing with conditionsl statement [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
if(cout<<"h"){}
this gives me an output
h
Any idea why, I have tried many variations of it and it still works.
That's because the if statement needs to evaluate the condition you give into it, plus, streams are implicitly convertible to bool.

Regular Expression for set of double number with semi-colon delimeted [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
Today I attemped several time to build regular expression to validate a set of double number with semi-colon delimeted following example data below:
Should match:
123.1234567890
123.1234567890;123.1234567890;123.1234567890
Should not match:
123.1234567890;
123.1234567890;123.1234567890;123.1234567890;
If you have any idea, Could you please help me ?
Thank you very much
You can try this:
(\d+\.\d+;)*\d+\.\d+(?![\d;])
to match the whole 123.1234567890;123.1234567890;123.1234567890
\d+\.\d+(?![\d;])
to match just the last.

Turning a string that contains a equation into an integer [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I would like to be able to convert a string such as "(5+6)*6" and get the resulting integer from that equation. It is important that it starts out as a string.
You can use library fastmathparser for c++.
In link is example how use this library.
If you really want write alone this parser, I recomended use Shunting-yard algorithm

Regex Expression Required [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
i am new to this regex thing, how can we build regex expression for following thig
input==>[User:1490474408:michaelayliffe]
output should be ==>1490474408
input will be anything like below:
1.[User:1490474408:michaelayliffe]
2.[User:12345:dfhdfhdf]
3.[User:56789:utyutyutyu]
Output should be middle value.
Please reply.
(?<=\[User:)[^:]+
Using lookbehind should work for you.
/\d+/g
It is find digits those are middle of your string