Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,185 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,393 people online right now. Registration is fast and FREE... Join Now!




linked list problem!

 
Reply to this topicStart new topic

linked list problem!, annoying error

jv1986
21 May, 2008 - 05:27 AM
Post #1

New D.I.C Head
*

Joined: 21 May, 2008
Posts: 3

Hi guys, im struggling to find a solution to why the below code is giving me the error

cc linktest3.c -o linktest3
linktest3.c:18: error: expected ‘)’ before ‘record’
linktest3.c: In function ‘main’:
linktest3.c:29: warning: assignment makes pointer from integer without a cast
make: *** [linktest3] Error 1

Ive sat and looked at this for a good while and its starting to give me a head ache. I have commented line 18.

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

typedef struct student {
    char ID[10];
    char Name[50];
    char Date[10];
    float Min_temp;
    float Max_temp;
} record;

typedef struct node_record {
    struct student data;
    struct node_record *next;
} NODE;

NODE *record_create(data record) {      /*line 18*/
    NODE *node;
    if(!(node=malloc(sizeof(NODE)))) return NULL;
    node->data = record;
    node->next = NULL;
    return node;
}

int main() {
    NODE *record_list;

    record_list = record_create((record) {"12","bob","12/12/12",3,4});

    return 0;
}


If anyone has any pointers as to why this is happening I would be very greatful.

This post has been edited by jv1986: 21 May, 2008 - 05:29 AM
User is offlineProfile CardPM
+Quote Post

jv1986
RE: Linked List Problem!
21 May, 2008 - 05:58 AM
Post #2

New D.I.C Head
*

Joined: 21 May, 2008
Posts: 3

Problem solved actually woohoo!
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/4/08 11:28AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month