Word Wrap Function not working..

This function is meant to insert a newline character only after a full word (does not cut a word in half) but before the max width is reached. I have to use pointers for this assignment, so I'm not sure if the problem lies in the actual function itself or my lack of knowledge when it comes to pointers. So here's my function:

#include "header.h"

void WordWrap (MovieNode* &ptr, MovieNode* &head, int count)
{
const int LINE_SIZE = 75;

int i;
int n;
bool stop;
int size;

stop = false;
i = LINE_SIZE;
ptr = head;

while (ptr != NULL)
{
size = (ptr -> plot).length();
while (i < size && !stop)
{
n = i + 1;
if (ptr -> plot[n] == ' ')
{
ptr -> plot[n] = '\n';
stop = true;
i = n + LINE_SIZE;
}
else
{
n--;
}
}
stop = false;
ptr = ptr -> next;
}


return;
}
Topic archived. No new replies allowed.