How to use PlaySound in C?

In C, how do I use scanf to read an equation in the format Ax+By=C?

  • I want the program to extract A, B and C from the equation ONLY if the input is in this format. Also, spaces are allowed but not between the variables to the coefficients: 5x + 5y= 3 is fine 5 x + 5 y = 3 should return an error. I tried scanf("%dx+%dy=%d",&A,&B,&C) where A, B, C are predefined integers. It did some of the input checking but not all of it: for instance, it accepts the first digit whether it's followed by an "x" or not. Also the spaces are not handled properly. Thanks for your answers

  • Answer:

    You cannot do that with scanf! It's much easier to do it with regular expressions. If you don't know whats a regular expression look here http://en.wikipedia.org/wiki/Regular_expression After learning that now you can use sscanf function (yes with double s) Example: int returned; returned = sscanf(string, "your reg ex", A, B, C); if you didn't understand it try searching for sscanf.

giladbr at Yahoo! Answers Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.