whipped up some code... there are probably typos and stuff but you'll get the general idea of simple pointer manipution, how to create new objects and setting struct attributes
Code:
#include<iostream>
using namespace std;
struct astruct
{
int attribute;
char another_attribute;
astruct *next;
};
//Function prototype: function will accept an astruct pointer and will return an astruct pointer
astruct* set_attributes(astruct*);
int main()
{
//Create a variable that will hold the memory address of a "astruct" object
astruct *my_struct;
//Create a new object in memory, and assign its location into a pointer variable
my_struct = new astruct;
//Who knows what kind of garbage data these variables might contain
cout << "\n\nHere is the unititialized struct: " << endl;
cout << my_struct->attribute << endl;
cout << my_struct->another_attribute << endl;
cout << my_struct->next << endl;
//Pass in the my_struct pointer and have my_struct accept the function's return pointer
my_struct = set_attributes(my_struct);
cout << "\n\nHere is the struct after being intialized: " << endl;
cout << my_struct->attribute << endl;
cout << my_struct->another_attribute << endl;
cout << my_struct->next << endl;
return 0;
}
//Function Definition(s)
astruct* set_attributes(astruct* temp_struct)
{
temp_struct->attribute = 42;
temp_struct->another_attribute = 'K';
temp_struct->next = new astruct;
return temp_struct;
}