variable help

I am supposed to write a program that takes the numbers of a file, finds the longest streak of ascending numbers, and returns the streak back. I am trying to find "streak" (or where the streak appears), but whenever I cout it returns as zero.

I know this is a hot mess, but here's what I have

int i = 0;
int j = 0;
int tryseq = 1;
int aseqcount = 0;
int streak = 0;

while (i < temp)
{
if (N[j].number < N[j+1].number)
{
tryseq++;
if (tryseq > aseqcount)
{
int aseqcount = tryseq;
int streak = j + 1;

}
else
int tryseq = 0;
}
j++;
i++;

}

aseqcount and streak return 0 every time I cout here but not in my tryseq > aseqcount.

Any ideas on how to fix this or is this way, way off base?
You're creating new ints within the try blocks :
1
2
3
4
5
6
	if (tryseq > aseqcount)
	{
		int aseqcount = tryseq; // here you're creating a new int variable in the if scope and hiding the original aseqcount variable declared above
		int streak = j + 1; // ditto

	}



See this : http://www.tutorialspoint.com/cplusplus/cpp_variable_scope.htm
Thank you kindly!
Topic archived. No new replies allowed.