Hi boys, I wrote this nice program in c++ a good deal was copied dev-c++ latest version keeps giving this error at the compilation : expected primary-expression before "struct"
I write here just the first part of the code till the mistake, you will find it at the line before the last.
I need it for a working interview and I am a bit nervous about it.
Thanks in advance-
Dora
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
//#include "sort_words.h"
struct word_item {
char * word;
struct word_item * next;
};
struct word_list {
int length;
struct word_item * first_word;
struct word_list * next;
};
struct word_list * first_word_list = NULL;
char * read_word(FILE * fin){
char c;
int i;
char * buffer = (char *)malloc(sizeof(char));
buffer[0] = '\0';
for (i=0; (c = fgetc(fin))!=EOF; i++) {
if (isspace(c) || ispunct(c))
break;
buffer[i] = c;
buffer = (char *)realloc(buffer, sizeof(char)*(i+1));
buffer[i+1] = '\0';
}
if (c == EOF)
return NULL;
return buffer;
}
/*
void init_word_list() {
first_word_list = NULL;
}
*/
struct word_list *
init_word_list_item(int length, struct word_list * next, struct word_item * item) {
struct word_list * word_list_item;
word_list_item = (struct word_list *) malloc(sizeof(struct word_list));
if (word_list_item == NULL) {
printf("cannot allocate enough memory\n");
exit(-1);
}
word_list_item->length = length;
word_list_item->next = next;
word_list_item->first_word = item;
return word_list_item;
}
/*void append_word_item(struct word_list * current, struct word_list * new) {
new->next = current->next;
current->next = new;
}*/
struct word_list * get_word_list_item(int length) {
struct word_list * cwl = NULL;
struct word_list * new = NULL; // Here the error is given
struct word_list * previous = NULL;