Strings Implementations |
|
The CString class provides a mechanism for deleting an occurrence of a certain string in another string. The function for performing this is called Replace. The CString::Replace() function allows you to control the content of a string especially if you are getting the string from an unpredictable source. Image the user is supposed to type a quadratic equation such as 3x^2+5. There are millions of ways the user can type it. The problem is that if you are planning on resolving the equation, before even getting to the solutions of the equation, you need to be able to "know" what the equation is made of; you cannot just try to retrieve a, b, and c. The user could type 3 x^2+ 5 or 3x ^2 +5 or 3 x ^ 2 + 5 or 3x ^2+ 5. As you can see, the possibilities are as numerous as imaginable. Remember that a string can consist of an empty space. Therefore, one of the first things you should perform is to remove any empty space in the equation. Eventually, you will use other functions to analyze the equation, find the parentheses if any, find the special characters such as ^ usually used to express the power in computer languages; you might also want to know if the user typed the equation in the form of Ax^2 + B = C.
|
|
||
Home | Copyright © 2002-2005 FunctionX, Inc. | |
|