I wrote a program to just output a single linked list and it works just fine, however it is outputting the last character twice (ex if the word to be outputted is DAD it outputs DADD)
#include <iostream>
#include <fstream>
using namespace std;
ifstream infile;
struct nodeType
{
char num;
nodeType *next;
};
int main()
{
infile.open("TextFile2.txt");
if (!infile)
cout << "Cannot open the file." << endl;
char digit;
nodeType *head = NULL, *trail = NULL, *current = NULL;
while (!infile.eof())
{
infile >> digit;
if (head == NULL)
{
head = new nodeType;
head->num = digit;
head->next = NULL;
trail = head;
}
else
{
current = new nodeType;
current->num = digit;
current->next = NULL;
trail->next = current;
trail = current;
}
}
current = head;
while (current != NULL)
{
cout << current->num;
current = current->next;
}
}