That is, the first element in your array is p[0] and the last is p[strings-1]
accessing p[strings] is stepping out of bounds of your array and is causing problems.
Take a look at your for loop:
1 2
// for(int i = 1; i <= strings; i++) // <- bad, starts at 1, ends at 'strings'
for(int i = 0; i < strings; ++i) // <- good, starts at 0, ends at 'strings-1'
As a very general rule, when programming... start counting at 0, not at 1.