simple text editor using doubly linked list adt

Hi everyone, this is the code i find on the internet about doubly linked list, i understand almost the code except void main(), can anyone explain for me the void main(), i can't understand it, and what the variable "col" is, thanks
#include <iostream.h>
#include <fstream.h>
#include <assert.h>
typedef struct Node
{
char character[80];
Node *next, *pre;
}Line;
Line *currentline;
Line *firstline;
Node *head, *tail;
int col;
void createfirstline()
{
Node *p;
p = new Node;
currentline = p;
head = currentline;
tail = currentline;
col = -1;
}
void newline()
{
Node *p;
p = new Node;
p -> next = NULL;
p->pre = currentline;
currentline->next = p;
tail = p;
currentline=p;
col = 0;
}
void createnewline()
{
Node *p;
p = new Node;
p -> next = NULL;
if (head == NULL)
{
head = p;
tail = p;
}
else
{
Node *q = tail;
q->next = p;
p->pre = q;
}
tail = p;
currentline = p;
}

void main()
{
cout << "Enter string: ";
char string[30];
cin.getline (string,30);
ifstream instream;
instream.open(string);

char reading;
currentline = firstline;
createfirstline();
while(instream.read(&reading,sizeof(reading)))
{
if (reading == '\n')
newline();
else
{
col++;
currentline->character[col] = reading;

}
}
instream.close();
}


Last edited on
Well main should return an int:

1
2
3
4
5
int main()
{
   ...
   return 0;
}

col is an int defined globally at the top
and it makes a really compilcated of opening and reading a file
Topic archived. No new replies allowed.