You can't even think about a linked list, if you aren't able to get the equation from the user.
This
doesn't work because you declare "eq" as a char, i.e. you can only store a single character in it.Code:int main() { char eq; ... scanf("%s", &eq);
Strings in C are special char arrays terminated with '\0'.
Do you know how to declare a char array?
For a start try to make a program which reads a string from the user and then loop through the string and print every single character. I recommend using fgets() for the reading part because scanf("%s") only reads until the first whitespace character. Is the user allowed to use spaces between operands/operators?
Generally, you should always work on a program like that. Work on one small part and only continue to the next when you are sure that everything works. Read also A development process.
Compile often and turn on all compiler warnings and learn to understand them.
Bye, Andreas



5Likes
LinkBack URL
About LinkBacks




