last one.
I solved the problem by neutralizing some functions I wasn't using but that I
had in other c++ files, thanks to comments, and the problem disappeared in
the main function. I then decided to pursue my coding, using a sortArray
function.
I now have to problems:
- when I pass an array to a function it looks like the function doesn't know
the size of my array but just nows the first element. I can also pass the
side as a second parameter but I guess we can do better.
- whe the compiler arrives to a line including the mathematical pow
function, it doesn't recognize it fully (when I write it in the code
InteliSense suggests me the parameters because he sees the definition in
math.h that I included, but whenI put my expresson in the watch window the
IDE says "Error: symbol pow not found", and when I F11 my code and I arrive
to the pow statement the compiler asks me for an asm file and if I don't give
him any he starts going in the deassembly ://)
here is the code:
-----------------------------------------------------------------------------------------
#include <iostream>
#include <math.h>
using namespace std;
int * sortArray(int iArray[],int arraySize);
void main(void)
{
int myArray[7]={6,3,5,7,1,2,4};
int sizeOfArray;
sizeOfArray=sizeof(myArray)/sizeof(int);
int * mySortedArray;
mySortedArray=new int [sizeOfArray];
mySortedArray=sortArray(myArray,sizeOfArray);
for (int i=0;i<=sizeOfArray-1;i++)
{
cout << mySortedArray[i] << '\n';
}
system("Pause");
int a;
a=1;
a++;
}
int * sortArray(int iArray[],int arraySize)
{
//int arraySize;
int lMin;
int intMax;
int minIndex;
//arraySize=sizeof(iArray)/sizeof(int);
int * iResult;
iResult=new int[arraySize];
intMax=pow(2.,double(8*sizeof(int)))/2-1;//2147483647;
for (int i=0;i<=arraySize-1;i++)
{
lMin=intMax;
for (int j=0;j<=arraySize-1;j++)
{
if (iArray[j]<=lMin)
{
lMin=iArray[j];
minIndex=j;
}
}
*(iResult+i)=lMin;
iArray[minIndex]=intMax;
}
return iResult;
}
-----------------------------------------------------------------------------------------
the result is fine when I do F5 but when I do F11 it doesn't recognize the
pow.
Do you get the same behaviour?
Thanks for the help.
"William DePalo [MVP VC++]" wrote:
"Fil" <Fil@discussions.microsoft.com> wrote in message
news:1B6F48F3-D7F0-43DC-91EF-A419E4961AC8@microsoft.com...
I was debugging the below code step by step:
----------------------------------------------------------------------------
#include <iostream>
using namespace std;
void main(void)
{
...
}
----------------------------------------------------------------------------
when I was suddenly asked whether I wanted or not to show the disassembly.
The question was asked when I was trying to execute the last line.
Do you have any idea why?
My guess is that you were single-stepping and for some reason the IDE could
not find the source code for main()'s caller in the CRT as you stepped out.
Because it had no source, it asked in effect if you wanted to debug at the
level of machine code.
Regards,
Will
www.ivrforbeginners.com