Hi,
I have this simple file that is supposed to create a Node struct to form a linked list. Basically what I want is for the user to be able to enter as many strings as he or she wants and for each new string the program creates a new "Node" and assigns 'nvalue' to the string and the 'ptr' of the last node, which is a node pointer, to point to the new node. Here is the code that I have implemented so far (just testing out basics), but it won't compile:
Error:Code:#include <cstdlib> #include <iostream> #include <string> using namespace std; struct Node { string nvalue; Node *ptr; } int main(int argc, char *argv[]) { // line 14 Node myNode; cin >> myNode.nvalue; cout << "You inputted: " << myNode.nvalue; System("Pause"); return 0; }
Code:14 test.cpp new types may not be defined in a return type 14 test.cpp extraneous `int' ignored 14 test.cpp `main' must return `int' 14 test.cpp return type for `main' changed to `int'



LinkBack URL
About LinkBacks



I used to be an adventurer like you... then I took an arrow to the knee.