Why don't you put some couts and check the values of 'Position' ? and btw you are leaking a lot of memory.
Agni
Practically a Master Poster
655 posts since Dec 2007
Reputation Points: 431
Solved Threads: 116
...
and btw you are leaking a lot of memory.
bryansworld, welcome to the world of C++ !
You're indeed leaking a lot of memory:
> What are you using variable 'strHolding' for ?
> Not very clever to insert the instruction strWord = new string[Position]; inside a loop as the program will always assign new memory and the old will still be allocated, but you don't have access to it anymore because you aren't having any pointer which is pointing to that memory ...
After you've rewritten your program:
> You shouldn't forget to release the allocated memory when it isn't needed anymore ...
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243
BTW, Position =+ 1; is always setting variable Position to 1 ...
I think you meant Position += 1;
(if your intention was to increment variable Position each time with one)
As a result your program will throw itself into an infinite loop (*) where it's always allocating more and more and more ... memory which explains the crash ...
(*): You're always checking whether Position < 47 , but this is always true as Position =+ 1; is everytime setting Position's value to 1, and 1 is always lower than 47
I hope this explains your mistake(s) !
tux4life
Nearly a Posting Maven
2,350 posts since Feb 2009
Reputation Points: 2,134
Solved Threads: 243