Code:
#include <stdio.h>
#include <stdlib.h>
typedef struct linkledlist {
char data;
struct linkedlist *nextptr;
} DEFINE;
void insert(DEFINE **,char);
int main(int argc, char *argv[])
{
DEFINE *startptr;
startptr=NULL;
startptr->nextptr=NULL;
printf("Choose what to do (1) to add , (2) to delete , q to quit....");
char selection;
char toadd;
scanf("%c",&selection);
switch(selection) {
case 1:
{
printf("Enter character to add :");
scanf("%c",&toadd);
printf("x");
insert(&startptr,toadd);
} }
printf("%c",startptr->data);
return 0;
printf("x");
}
void insert(DEFINE **sptr,char value) {
DEFINE *newptr=malloc(sizeof(DEFINE));
DEFINE *previous;
DEFINE *current;
if(newptr!=NULL) {newptr->data=value;
newptr->nextptr=NULL; }
previous=NULL;
current=*sptr;
while(current!=NULL && value>current->data) {
previous=current;
current=current->nextptr;} ////////////////
if(previous==NULL) {
newptr->nextptr=*sptr; ////////////////////////////
*sptr=newptr; }
else {
newptr->nextptr=current; /////////////////////////
previous->nextptr=newptr; }//////////////
}
It will be a program which is capable of adding chars and deleting chars from a linkedlist. But I get this error from compile :
55 C:\Dev-Cpp\projects\main.c [Warning] assignment from incompatible pointer type
It gives this error , for all the lines I have mentioned by slashes. 'd be glad if you helped.