When you're including a file that is in the same folder as the source code, you must use quotation marks.
CODE
#include "stack.h"
If you used <> then it won't work because the preprocessor only searches through certain directories for the file name. Take your extra functions and stick them in a file called stack.h the use the #include statement in the code block above. That should fix your problem.
Also your pointer warnings mean that you're trying to assign a value to a variable when the variable is not of the same type as the value. For example
int a = "hello world" is an example of that. Yours are more subtle because you're assigning char* to chars.
A pointer is a type that holds the memory location of a variable.
CODE
int a = 5, *b;
b = &a; /* assign the memory location of a to the value of b
the ampersand (&) gives the memory location of a variable.
&a is the same thing as b.
the asterisk (*) assumes that the value of a variable is a
memory location and then fetches the value AT that memory location
a is the same thing as *b
*/
back to your code.
In your pop function you have this code:
stack[top] = " ";now " " is a char*, but stack[top] is a char. If you want to put an empty space in your stack, then do this:
stack[top] = ' ';At the beginning of your stacktop function you have this code:
stack[top] = datastack and data are both char arrays, which are used the same way as char*. You're essentially trying to assign a char* to a char.
In your main function you try to assign the memory location of data to ptrdata. Since data is an array, and therefore a pointer all that is necessary for data and ptrdata to reference the same memory is
ptrdata = dataYour
while (*ptrdata != NULL) is also erroneous because you're attempting to compare the value referenced by ptrdata and NULL. What you should be trying to do is compare the value of ptrdata and NULL.
while(ptrdata != NULL)And finally, I think you're trying to test if the stack array is empty. Instead of comparing it to NULL, why don't you just test the value of the
top variable? Since it looks like top holds the index of the first element, and when
stack is empty top should be -1, just test if top is -1, and then your stack is empty.