#include <iostream> #include <conio.h> using namespace std; struct list { string oldState, symbol, newState; list *next; }; list *field = NULL; list *start = NULL; void addList(string oldState, string value, string newState) { if (field == NULL) { field->oldState = oldState; field->symbol = value; field->newState = newState; field->next = NULL; //start = field; } else { while (field) { field = field->next; if (!field) field = new list; } field->oldState = oldState; field->symbol = value; field->newState = newState; field->next = NULL; } } int main() { addList("1", "2", "3"); cout << field->oldState << field->symbol << field->newState; return 0; }
I apparently completely confused with these pointers, or something I do not understand. Explain why this is not working?