im getting the error below and I can't figure out why this isn't working. Ive looked at this for 2 days not knowing. I'm hoping a fresh set of eyes on it might help.

main.c:13: warning: assignment makes pointer from integer without a cast

//HEADER FILE:
#include <stdlib.h>
#include <stdio.h>
#define my

typedef char KEY_TYPE;
typedef struct
        {
             KEY_TYPE key;
        }  DATA;
typedef struct nodeTag
        {   DATA data;
            struct nodeTag* link;
        } NODE;

// PRINTLIST FUNCTION:
#include "my.h"
#include <stdio.h>
void printList (NODE* pList)
{
NODE* pWalker;
    pWalker = pList;
    printf("The linked list is ");

    while(pWalker)
    {
        printf("%c", pWalker->data.key);
        pWalker = pWalker->link;
    }
    printf("\n");
    return;
}

//MAIN FUNCTION:
 
#include "my.h"
#include <stdio.h>

int main(int argc, char *argv[])
{

NODE* pList;
FILE* p;
 NODE* pPre = NULL; DATA item; int y;
p = fopen(argv[1],"r");
while(y=fscanf(p,"%c", &(item.key))!= EOF);
{
        pList = insertNode(pList,pPre,item);
}
printList(pList);
countVowels (pList);
countChars (pList);
return 0;
}

//INSERTNODE FUNCTION:
 #include "my.h"

NODE* insertNode(NODE* pList, NODE* pPre, DATA item)
{
    NODE* pNew;

    if(!(pNew = (NODE*)malloc(sizeof(NODE))))
        printf("\aMemory overflow in insert\n");
            exit (100);
    pNew->data = item;
    if (pPre == NULL)
    {
        pNew->link = pList;
        pList = pNew;
    }
    else
    {
        pNew->link = pPre->link;
        pPre->link = pNew;
    }
    return pList;

//VOWELS FUNCTION:
 
#include "my.h"

void countVowels(NODE* pList)
{
int count;
NODE* pWalker;
    while(pWalker)
    {
        if (pWalker->data.key =
'A'||'E'||'I'||'O'||'U'||'a'||'e'||'e'||'i'||'o'||'u')
            count++;
        pWalker = pWalker->link;
    }
    printf("The number of vowels is %d", count);
    printf("\n");
    return;
}

//CHARS FUNCTION:
 
#include "my.h"

void countChars(NODE* pList)
{
NODE* pWalker;
int count;
    while(pWalker)
    {
        count++;
        pWalker = pWalker->link;
    }
    printf("The number of chars is %d",count);
    return;
}

line 87: pWalker is an uninitialized pointer and your program is bound to crash. You need to initialize it with the value of the parameter pList. As for the problem you asked about, please tell us which line in the code you posted the error occurs.

Edited 5 Years Ago by Ancient Dragon: n/a

This article has been dead for over six months. Start a new discussion instead.