Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m having problems with my code and Ive looked at it for days and can\'t under

ID: 3634739 • Letter: I

Question

I'm having problems with my code and Ive looked at it for days and can't understand how to fix it. I think a fresh set of eyes will be able to tell me what I'm just not seeing. Thanks all!

header file:
#include <stdio.h>
#define my

typedef char KEY_TYPE;
typedef struct
{
KEY_TYPE key;
} DATA;

typedef struct nodeTag
{ DATA data;
struct nodeTag* link;
} NODE;


Main:
#include "my.h"
#include <stdio.h>

int main(int argc, char *argv[])
{
NODE* pList;
FILE* p;
pList = NULL; 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);
}
countVowels (NODE* pList);
countChars (NODE* pList);
return 0;
}

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

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


this is the error i keep getting:
main.c:13: warning: assignment makes pointer from integer without a cast
(the pList=insertNode line)

Explanation / Answer

Hi i can find three errors in your codes.

1. DATA is a structure and to access it's member you need dot(.) operator not -> operator.
while(y = fscanf(p, "%c", &(item->key)) != EOF);

wrtie while(y = fscanf(p, "%c", &(item.key)) != EOF);

2. Your while loop is ending on the same line so check it

while(y = fscanf(p, "%c", &(item->key)) != EOF);--------- you have put ; at the end of the line

3. pList = insertNode(pList,pPre,item); -------- as you have not given the code of the function insertNode()

But still check the return type of that function. As you have written pList = insertNode() so the return type of the function should not be void. If your function does not return any value then remove "pList=" from the line no 13.

All the best for your project !!!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote