As you can see this is my program.my problem is how to store strings in my program
I can store only single character..
any one can help me?
=(
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define p printf
#define s scanf
struct node
{
char nbook;
struct node *next;
};
typedef struct node *nodepointer;
void addbook(nodepointer &head,char book)
{
nodepointer newnode;
newnode=(nodepointer)malloc(sizeof(struct node));
newnode->nbook=book;
newnode->next=head;
head=newnode;
}
void display(nodepointer head)
{
if(head==NULL)
{
p("\nNothing to display");
}
else if(head!=NULL)
{
while(head->next!=NULL)
{
p("\n%c",head->nbook);
head=head->next;
}
p("\n%c",head->nbook);
}
}
main()
{
nodepointer head=NULL;
int choice;
char book;
do
{
p("\n[1]Add book");
p("\n[2]Display book");
p("\nKey choice: ");
s("%i",&choice);
switch(choice)
{
case 1:
p("\nEnter title of book");
s("\n%c",&book);
addbook(head,book);
break;
case 2:
display(head);
break;
}
}while(choice!=4);
system("pause");
}