C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Char Error

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Will Oram
Guest





PostPosted: Thu Oct 30, 2003 1:14 am    Post subject: Char Error Reply with quote



Xcode, OS X's toolkit, compiles this, but chokes if anything (here, a '(
' char) is inputted. Its goal is to take an input string character by
character and put it in a linked list.

The output and error:

-------
EVALUATE THIS MATH EXPRESSION (no spaces or letters, please):
(
ZeroLink: unknown symbol '__ZN5StackIcE4pushERKc'

233_PA2_part2 has exited with status 1.
-------

...and the code (assume all pointers begin initialised as NULL):

-------
int main () {
Stack<char> myStack;

bool isValid = TRUE;

char expression[CAPACITY];
char currentChar = ' ';
char previousChar = ' ';

cout << "EVALUATE THIS MATH EXPRESSION (no spaces or letters, please):
n";
cin >> expression;

for (int j = 0; currentChar != ''; ++j) {
previousChar = currentChar;
currentChar = expression[j];

if(!evaluateChar(currentChar, previousChar, myStack))
isValid = FALSE;
} }
}
-------

...which eventually calls the push function through evaluateChar:

-------
template <class Item>
void Stack<Item>::push(const Item &entry) {
Node *newChar;
newChar = new Node;

Node *test;
test = new Node;

bottom_ptr = newChar;
newChar -> data = entry;
newChar -> next = NULL;

if(empty())
top_ptr = newChar;

for (test = top_ptr; test != NULL; test = test -> next)
cout << test -> data << endl;
}
-------

I think it has something to do with main; doing functionwide commenting
out shows that it runs fine if push but not main is commented out.

Thanks.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.