Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8570401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:32:59+00:00 2026-06-11T18:32:59+00:00

#include<stdio.h> #include<stdlib.h> #include<ctype.h> #include<string.h> struct person *create_node(char *, char *,int); void addnode(char *,char *,int,struct

  • 0
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>

struct person *create_node(char *, char *,int);
void addnode(char *,char *,int,struct person *);


struct person
{
   char fname[20];
   char sname[20];
   int pno;
   struct person *next,*prev;
};

struct person *create_node(char *first,char *second,int mob)
{
   struct person *pnode=(struct person *)malloc(sizeof(struct person));
   strcpy(pnode->fname,*first);
   strcpy(pnode->sname,*second);
   pnode->pno=mob;
   pnode->next=pnode->prev=NULL;

  return pnode;

 }

 void addnode(char *first,char *second,int mob,struct person *pnode)
 {
   while(pnode->next!=NULL)
   {
        pnode=pnode->next;
   }
   pnode->next=create_node(first,second,mob);
   pnode->next->prev=pnode;

 }

 int main()
 {
   struct person *root=NULL;
   char choice='y';
   char first[20];
   char second[20];
   int mob;

   while(tolower(choice)=='y')
  {
        printf("enter the first name:");
    scanf("%s",first);

    printf("enter the second name:");
    scanf("%s",second);

    printf("enter the mobile no:");
    scanf("%d",&mob);

    if(root==NULL)
    root=create_node(first,second,mob);
    else
    addnode(first,second,mob,root);
    printf("enter the option to continue or end(y or n):");
    scanf("%c",&choice);
    fflush(stdin);
  }

  return 0;
  } 

This is the program I have written,what it basically does is,it will create linked list taking the values of the structures from the users.

I got 2 similar warnings when i run this program from the function

    struct person * create_node(char *, char *, int),
    passing char to argument 2 of strcpy(char *, const char *) lacks a cast

I don’t understand why it is passing const value to the function.

And I have one more problem with this program.The program stops working after I enter the information for first node.

I am using gcc compiler on windows platform.
Please help me out.
Thanks…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:33:00+00:00Added an answer on June 11, 2026 at 6:33 pm

    The problem is not that. The problem is that you’re passing *first and *second as the second argument for strcpy() which are chars and not char pointers. You must simply pass first and second, the pointers themselves.

    Also, please do not cast the return value of malloc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My code #include <stdio.h> #include <stdlib.h> #include <ctype.h> void getData(short int *number, char *string)
#include<stdlib.h> #include<string.h> #include<stdio.h> int pstrcmp( char **p,char **q) { return strcmp(*p,*q) ; } int
#include<stdio.h> #include<stdlib.h> struct node { int data; struct node *next; }; void insert( struct
#include<stdio.h> #include<string.h> #include<stdlib.h> int main() { // int char str[40],ch; FILE*fp,*fp1,*fp2; fp=fopen(ide_input,w); fp1=fopen(error_log,w); fp2=fopen(lex_output,w);
#include<stdio.h> #include<stdlib.h> char* re() { char *p = hello; return p; } int main()
#include <stdio.h> #include <stdlib.h> int main(void) { int x; int *in, *begin; in =
#include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { if(argc != 2) return
#include <stdio.h> #include <stdlib.h> #include <time.h> void initDeck (int deck[]); void showDeck (int deck[]);
#include<stdio.h> #include<signal.h> #include<stdlib.h> void handler(int signo) { printf(First statement); system(date); exit(EXIT_SUCCESS); } int main()
#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #include dictionary.h #define HASH_SIZE

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.