Thread: how to change char to formula

  1. #1
    Registered User
    Join Date
    Jun 2003
    Posts
    5

    how to change char to formula

    Hi,,,

    I want to do like this...

    for example.. i have a file call formula.txt
    so,, in the file,, i wrote a formula for example

    x*x*x +2*x

    Of coz, this formula is considered as string isn't it??

    So,, from a C program,, how can i read this content and change it to a meaning math formula...

    in another mean,,
    after read the content from formula.txt,,,

    i want to like this,,

    f(x) = x*x*x +(2*x)

    and then do loop to generate f(x)...


    please help me....

  2. #2
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    You will need to read it into a string and then write a function yourself to evaluate the expression with a given value for x. For the loop you could call the function n times with different values for x.

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    5
    thanks shiro san..

    do you mean that i have to write function to split token (like * , + , - , ), ( , and so on) and parameter x ???

    wowwww... impossible for me.. may be.!!!

    could you suggest me a simplest algo to write it?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code review
    By Elysia in forum C++ Programming
    Replies: 71
    Last Post: 05-13-2008, 09:42 PM
  2. Sorting Linked Lists
    By DKING89 in forum C Programming
    Replies: 6
    Last Post: 04-09-2008, 07:36 AM
  3. Replies: 6
    Last Post: 06-30-2005, 08:03 AM
  4. String sorthing, file opening and saving.
    By j0hnb in forum C Programming
    Replies: 9
    Last Post: 01-23-2003, 01:18 AM
  5. simulate Grep command in Unix using C
    By laxmi in forum C Programming
    Replies: 6
    Last Post: 05-10-2002, 04:10 PM