jweinst1
3/26/2017 - 9:49 PM

simulates objects in c with a node and print method

simulates objects in c with a node and print method

#include <stdio.h>
#include <stdlib.h>

//object constructor in c


typedef struct node {
    char data;
    int order;
} node;


node init_node(char d, int o){
    node obj;
    obj.data = d;
    obj.order = o;
    return obj;
}

void print_node(node n){
    //prints th contents of the node
    printf("{data=%c", n.data);
    printf(" order=%d}\n", n.order);
}



int main() {
    node g = init_node('e', 4);
    print_node(g);
    return 0;
}