I am trying to create a linked list that will store words and how many times they occurred in the .txt file. Before reading I'm trying to create a linked list to see if it is okay. While testing, it is crashing.
#include <iostream>
#include <string>
struct n {
std::string word;
int occurance;
n* next;
};
typedef n node;
int main() {
node* root;
root = (node*)malloc(sizeof(node*));
root->word = "test";
root->occurance = 5;
std::cout << root->word
<< root->occurance << std::endl;
}