using information from an array

This is a discussion on using information from an array within the C Programming forums, part of the General Programming Boards category; i have a scanf that puts an equation such as: x*x+x-2 into an array. what i want to do with ...

  1. #1
    Unregistered
    Guest

    using information from an array

    i have a scanf that puts an equation such as: x*x+x-2 into an array. what i want to do with the array is thus... use the equation to calculate something somehow. i am unable to say blah = array because it is trying to assign the array to blah. how can i utilize the information inserted into the array as an equation rather than simply information in the array? please at least reply letting me know if i have not provided enough information. thank you.

  2. #2
    wavering
    Guest

    Java Script eval() Equivalent Needed

    I take it that you have the formula held in a string and wish to excute it as a program instruction? Certainly you can do this in Java Script ( which is a a sort of C derived language ) using the eval function eg

    str="x=5;y=7;x*y";
    eval(str);

    gives "35" etc. You can use it to pass programs around the net as strings and execute them. For instance, if you have an asp routine on a server you can pass variables or even lines of code to a Java Script program on the client machine. This can hugely speed up web sites by cutting out the long wait every time the client pushes a button ( because all the code is on his machine already )

    Now for C and an awful confession! I only have three days C programming experience and it will take me at least three more days ( four if I have to understand pointers ) to become an expert.

    So, does C have an equivalent function to eval??

  3. #3
    Unregistered
    Guest
    Not that I know of. I don't know how to use what the user enters as an actual computable equation in my code, I only know how to edit or view the array that I stored it in.

  4. #4
    Unregistered
    Guest
    Yeah... That's exactly my problem.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need some good information on Array, strings, and pointers
    By Sshakey6791 in forum C++ Programming
    Replies: 4
    Last Post: 11-30-2008, 02:16 AM
  2. Replies: 9
    Last Post: 08-09-2008, 10:47 AM
  3. array decade pointers information
    By sawer in forum C++ Programming
    Replies: 8
    Last Post: 05-02-2007, 01:08 PM
  4. Array help
    By deedlit in forum C Programming
    Replies: 4
    Last Post: 11-05-2003, 09:55 AM
  5. Creating 2D arrays on heap
    By sundeeptuteja in forum C++ Programming
    Replies: 6
    Last Post: 08-16-2002, 11:44 AM

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