Joined: Mon Jul 20, 2009 10:26 pm Posts: 1 Has thanked: 0 time Have thanks: 0 time
Hi, I am having trouble with a c++ program I am trying to write. The program should be able to solve equations like "3 / ( 4 * 5 ) =" however when i run it a get a runtime error (Unhandled exception). The program is not entirely finished but I can't continue untill i figure this out. It must use a doubly linked list. I am a beginning programmer so please take the time to explain everything, and stick with the simplist code.
Thanks for your time.
Code:
//program needs to be able to solve equations like 3 / ( 4 * 5 ) = //note: when imputing equation, separate each character with a space and end it with a “=†//when I run the program, I get a runtime error – not sure why
dll = new node; head = dll; tail = dll; head ->prev = 0; head -> op = '('; head -> type = 'o'; head -> value = -1;
while (str[0] != '=') //check for end of expression, doesn't include = sign. Loop will get all imput and put it into a doubly linked list. { if (isdigit(str[0])) { tail->next = new node; tail->next->prev = tail; tail = tail->next; tail->value= atoi(str); tail->type='n'; tail->op='$'; } else { tail->next = new node; tail->next->prev = tail; tail = tail->next; tail ->op = str[0]; tail->type='o'; tail->value=-1; } cin >> str; }
Joined: Fri Nov 21, 2008 6:18 pm Posts: 50 Location: thessaloniki Has thanked: 0 time Have thanks: 0 time
what exactly you want to create a calculator withc solves arithmetic combinations of a kind ..or something exact such as 3/(5*4) ?? you only want to be able to pick up the numbers or what i was looking the lines of your code the 2 last lines temp = ...etc definatly rong
Users browsing this forum: No registered users and 2 guests
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum