#include<stdio.h>
#include<conio.h>
struct adj_node  
{
char nam;
struct adj_node *adj_next; 
};
struct node 
{
char name;
struct adj_node *down;
struct node *next;  
};
struct node * gins(struct node *);
struct node * lins(struct node *);
main()
{
      int n,i,j;
      char c,r;
      struct node *g,*t;
      g=malloc(sizeof(struct node));
      g->next=NULL;
      g=gins(g);
      g=lins(g);
      getch();
         }


struct node * gins(struct node *a)
         {
       char c;
      do
      {     
       printf("n enter  vertex else a spacen");     
       scanf("%c",&c);         
       fflush(stdin);
       if(c!=' ')
       {
       a=a->next;
       a=malloc(sizeof(struct node));      
       a->name=c;
       a->next=NULL;
       }
       }while(c!=' ');
       return a;
       }

struct node *  lins(struct node *a)
        {
             char c;
       do 
       {
           a=a->next;
       do
       {  
         printf("n is there any edge incedented on vertex %c Y or N n",a->name);
         scanf("%c",&c);
         fflush(stdin);
         if(c=='Y')
         {
          a->down=malloc(sizeof(struct adj_node));
         printf("n enter the other vertex of the edge incedented on %cn ",a->name);
         scanf("%c",&a->down->nam);
         fflush(stdin);
         a->down->adj_next=NULL;
         a->down=a->down->adj_next;
         }
         else
         {
          a->down=NULL;
          }   
         }while(c!='N');
         a=a->next;
         }while(a->next!=NULL);
         return a;
         }

when i am executing the program and giving input as shown in the image
i am unable to proceed with my execution
the sample graph which i am using is also shown in image
can some one tell me what am i supposed to do for continuing execution

The error you're getting typically means there's an access violation. Access violations are typically caused by invalid pointers, so your first line of attack should be to step through your code in a debugger and keep a close watch on your pointers to make sure that they're valid at any given time.

can u please tell me where should i modify the code and continue my execution ....

No offense, but while I could do your debugging for you and tell you exactly what the problem is and how to fix it, you wouldn't learn jack from that. Given that this is the first of many, many, many access violations you're sure to encounter, you'd benefit greatly from learning how to troubleshoot the problem on your own in a very simple program.

i hate decepticons ........i want optimus prime to help me out...........some one correct my program and let me continue my execution .............

some one correct my program and let me continue my execution .............

I did take a look at the code, and you're clearly dereferencing null pointers. Here's one example:

a=a->next;
a=malloc(sizeof(struct node));      
a->name=c;
a->next=NULL;

The first a = a->next makes a a null pointer. Why? Because a is equivalent to g from main(), and while g is a valid node object, g->next is NULL. So what you need to do is allocate memory to a->next, then move to the new node.

But this still doesn't fix the problem because you're basically throwing away all references to the objects you're creating by modifying a directly and then returning it to be assigned to g.

The following gins() at least allows the program to run to completion for a very simple test.

struct node* gins(struct node* a)
{
    struct node* p = a;
    char c;

    do
    {     
        printf("\n enter  vertex else a space\n");     
        scanf("%c", &c);         
        fflush(stdin);

        if (c != ' ')
        {
            p->next = malloc(sizeof(struct node));      
            p = p->next;
            p->name = c;
            p->next = NULL;
        }
    }
    while(c != ' ');

    return a;
}

Learn to do that yourself. It's very important, and I'm not going to do it for you a second time. You strike me as exceptionally lazy and helpless, and your presumptuous attitude about deserving freebies is irritating as well.

i got the output what i wanted i was working on this code for 1 week
deceptikon talks more but he could not help me
i am uploading an image
now i will not show my code to this world
i will work for those who will pay me lot of money ...........

commented: Maybe it's a language barrier, but lots of rude and presumptuous remarks in this post. -2

in all codes nowhere i have asked to enter the number of vertices or edges at the beginning of programme
i am demanding this huge amount of money to keep my mother happy
and to show my father that i am something special in this world ..............

i am sorry decepticon if i have hurted you

I'd be very impressed if you could manage to bother me at all, much less hurt me in any way. I really care very little about what you say or do, but it's my job as a moderator and administrator to enforce the rules.

i am demanding this huge amount of money to keep my mother happy

Please read our rules concerning spam. By the way, since it's devolved into little more than a sales medium for you, I'm closing this thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.