#include<iostream>
#include<string>
#include<conio.h>
using namespace std;

struct node{
       int num,ages;
       string name,skills;
       struct node *link;
       };
       typedef struct node *nodepointer;

       nodepointer add(nodepointer &head, int nu, int age);
       void str(nodepointer &head, string na, string ski);
       void DeleteFront(nodepointer &head); 
       void display(nodepointer head);

int main(){
    nodepointer head = NULL;
    int c,nu,age;
    string na,ski;
    
    do{
           up:
                system("CLS");
                cout<<"[1]Add wizard"<<endl;
                cout<<"[2]Delete wizard"<<endl;
                cout<<"[3]Search wizard"<<endl;
                cout<<"[4]Display wizard"<<endl;
                cout<<"[5]Exit"<<endl;
                cout<<"Choose from numbers 1-5"<<endl;
                cin>>c;
                
                switch(c)
                {
                         case 1:
                              cout<<"Enter number: "<<endl;
                              cin>>nu;
                              head = add(head,nu,age);
                              cout<<"Enter age: "<<endl;
                              cin>>age;
                              head = add(head,nu,age);
                              cout<<"Enter name: "<<endl;
                              cin>>na;
                              str(head,na,ski);
                              cout<<"Enter skill: "<<endl;
                              cin>>ski;
                              goto up;
                              getch();
                              break;
                         case 2:
                              DeleteFront(head);
                              getch();
                              break;
                         case 3:
                              getch();
                              break;
                         case 4:
                              display(head);
                              getch();
                              break;
                         case 5:
                              exit(1);
                              break;
                              }
                              }while (c!=0);
                getch();
                }

nodepointer add(nodepointer &head, int nu, int age)
{
         nodepointer newnode;
         newnode=(nodepointer)malloc(sizeof(struct node));
         newnode->num=nu;
         newnode->ages=age;
         newnode->link=head;
         head=newnode;
}

void str(nodepointer &head, string na, string ski)
{
         nodepointer newnode;
         newnode=(nodepointer)malloc(sizeof(struct node));
         newnode->name=na;
         newnode->skills=ski;
         newnode->link=head;
         head=newnode;
}

void DeleteFront(nodepointer &head)
{
nodepointer temp;
if (head == NULL)
printf("Linked list is empty…");
else
{
temp = head;
head = head -> link;
free(temp);
}
}

void display(nodepointer head)
       {
            if(head==NULL)
            {
                          printf("\n no data");
                          }
                          else
                          {
                          while(head->link!=NULL)
                          {
                                                 printf("Number: %i",head->num);
                                                 printf("\nAge: %i",head->ages);
                                                 printf("\nName: %s",head->name);
                                                 head=head->link;
                                                 }
                                                 }
}

can somebody what im doing wrong here?
if i only used numbers in linked list there are no errors but if started using string i just cant get it to work
can somebody help me?

For starters, get rid of the "up:" label and the "goto up;" jump statement (Lines 24 and 48 respectively), they are of no use to you as that's what your do-while loop is for.

Next. Please clearly explain exactly what the problem is; a statement like "I just can't get it to work" is not very useful. What sort of behavior are you expecting? What sort of behavior are you getting? How does the actual differ from the expected? etc... etc...

i can display integers in the linked list fine but i cant display the string it always comes out as an error

What error message do you get? We can't see your screen from here....

Also, why do you call add() twice from your input case (once after inputting num, and again after inputting age)? Why do you declare your "node" to contain two integers and two strings, but provide two separate functions (add() and str()) each of which creates a new node with only two out of four values provided?

Slow down. Think logically about what you're doing. Say it out loud. Write code that corresponds to what you say. If you can't write a couple of lines of code corresponding to a verbal "step" in your process, you're not thinking clearly yet. Re-start this paragraph.

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.