I'm trying to build an array of integers, in which the number of elements of the array is determined by the length of a string parameter (which is an integer). The intent is to build a list starting from 1, then 4,16,64,256,1024, etc, until it becomes greater than the number read in on the string.
The first problem is that the printout gives values of 5,6,7,0,1,2,3 before crashing, not the powers of four which I wanted it to.Code:string num(string a) { int list1[a.length()^2/2]; list1[0] = 1; for (int y=1; y < 2*a.length(); y++) { list1[y] = 4^y; cout << "list1 contains: " << list1[y] << endl; } }
Any ideas on how to tackle this?



LinkBack URL
About LinkBacks




Yeah... well about that... There was this thread about integer division...no, I won't go there again.