how to change char to formula

This is a discussion on how to change char to formula within the C Programming forums, part of the General Programming Boards category; Hi,,, I want to do like this... for example.. i have a file call formula.txt so,, in the file,, i ...

  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,386
    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, 10:42 PM
  2. Sorting Linked Lists
    By DKING89 in forum C Programming
    Replies: 6
    Last Post: 04-09-2008, 08:36 AM
  3. Replies: 6
    Last Post: 06-30-2005, 09: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, 05:10 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21