The user enters the following :

" x+sin(x)-pow(x,2)+5log(x)"

How can I make parsing for a statement like that .

vedro-compota commented: + +3

Recommended Answers

All 7 Replies

Look at the string character by character.

commented: + +3

I did . but I have no Idea .

I have just finished a Course in C and this is the final project .

Can you guide me to some teaching books or helpful websites

There are a variety of ways to do this; see these links for some ideas to get you started.

Basically this problem is identifying "strings of interest" log / sin / cos / (x)
You use the strtok function to identify the start and end of these kind of strings

Basically this problem is identifying "strings of interest" log / sin / cos / (x)
You use the strtok function to identify the start and end of these kind of strings

strtok modifies its target string. This is a bad thing if you want to search multiple times over several delimiters.

In almost all cases strtok is the wrong tool to use when parsing input.

Well I am lost

Describe why. Lot's of answers here, and since you finished the course, you must know how to work with arrays. What's your real problem?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.