Whats Wrong in My simple program?

This is a discussion on Whats Wrong in My simple program? within the C Programming forums, part of the General Programming Boards category; Code: #include <malloc.h> #include <stdio.h> struct list { int data; struct list next; }; typedef struct list node; typedef node ...

  1. #1
    Registered User
    Join Date
    Jul 2004

    Whats Wrong in My simple program?

    #include <malloc.h>
    #include <stdio.h>
    struct list
    int data;
    struct list next;
    typedef struct list node;
    typedef node link;
    link ptr,head;
    int num,i;
    printf("please input 5 numbers==>\n");
       if(i==4) ptr->next=NULL;
       else  ptr=ptr->next;
      printf("The value is ==>%d\n",ptr->data);
    what's wrong with it? help me, thanx..
    change the first error,thanx,may be i should rewrite this program,i am newbit , sorry at all...
    Last edited by MartinLiao; 09-02-2004 at 03:36 AM.

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Oregon, USA
    Your #include's are incorrect. Aside from missing the '#' for the first one entirely (probably a copy & paste error) you should use <> around the header name instead of "".

    You think you're using pointers, but you're not. Your 'ptr' variable is actually an instance of the struct; not a pointer to one.

    Your spacing and indenting is atrocious. Cleaning it up might reveal some errors.

    Get those things fixed and let us know if you're still having problems and what the problems actually are. What symptoms are you seeing? Try to be a little more specific than "what's wrong with it?" with no explanation of what's happening as opposed to what you expect to happen.
    If you understand what you're doing, you're not learning anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 02:42 AM
  2. Simple Blackjack Program
    By saber1357 in forum C Programming
    Replies: 1
    Last Post: 03-28-2009, 04:19 PM
  3. Replies: 5
    Last Post: 01-13-2007, 02:14 AM
  4. Help with small simple program
    By Sonor in forum C Programming
    Replies: 5
    Last Post: 04-02-2005, 07:40 AM
  5. simple frontend program problem
    By gandalf_bar in forum Linux Programming
    Replies: 16
    Last Post: 04-22-2004, 07:33 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21