Any help on this print function using a linked list. I am getting the print statement coming up twice.
Code:
#include "mystuff.h"
void countchar (NODE* pList)
{
// local declarations
int a;
int w = w;
int sum = 0;
NODE* pWalker;
pWalker = pList;
int testEOF;
// functions
while (testEOF != EOF)
{ printf("Enter a char to be counted for in the linked list: <EOF> to stop ");
testEOF = scanf("%c", &a);
while (pWalker)
{
w = (pWalker->data.key);
if (w == a)
sum++;
pWalker = pWalker->link;
}
printf("The number of %c's in the linked list is: %d\n", a, sum);
}
return;
}
The output: I entered an 'a' and it printed the print statement and then I hit ctrl+d and it printed again. Not sure what Is going on.
Code:
[n00611323@osprey a7]$ ./a.out data
b. The Linked list of chars reversed is: t d i m h c S n o r e m a C
c. The total number of vowels in the linked list is: 4
Enter a char to be counted for in the linked list: <EOF> to stop a
The number of a's in the linked list is: 1
Enter a char to be counted for in the linked list: <EOF> to stop The number of
's in the linked list is: 1
Enter a char to be counted for in the linked list: <EOF> to stop The number of
's in the linked list is: 1