Re: show disassembly



"Fil" wrote:
Is there something like VBE Ctrl+Shift+F8 to run in once the
content of the pow function?

Instead of pressing F11 (step into) you can press F10 (step over).
If you stepped in a function and want to go outside without
pressing F10 for each statement, then press Shift+F11.

Also, I suggest you to turn on shortcut keys display in tooltips.
Go to menu: Tools -> Customize..., then on "Toolbars" tab enable
"Show shortcut keys in ScreenTips" check box.

I thought I had to keep some space in the memory to store the
result of the function. Should I just write this:

int * mySortedArray;
mySortedArray=sortArray(myArray,sizeOfArray);

No, you don't need to allocate any space for sorted array. You
already have necessary space allocated. It is the space that
`myArray' occupies.

You don't need to return anyhting either. `myArray' is already
updated upon return from `sortArray':

// No need to specify array size, it will be inferred
// by the compiler from the initialization list.
// Necessary storage for myArray is allocated by
// the compiler on stack.
int myArray[]={6,3,5,7,1,2,4};

int sizeOfArray = sizeof(myArray)/sizeof(int);

// No need to return anything, myArray is passed by
// reference. All changes made within sortArray
// will be reflected in myArray.
sortArray(myArray, sizeOfArray);

Declaring all variables in the beginning of a function
considered
bad C-style, which is better to avoid in C++. Declare variables
as
close to their usage as possible.

That's cool because it will be easier to read, I was doing it
because I had
been told it was good style.

It is the only style for C language. However, C++ language doesn't
have this restriction.

You don't need to allocate new array.

But I am allocating for iResult, not for iArray. Shouldn't I?

You shouldn't. The necessary storage is already allocated for the
original `myArray' array. So, you can sort it in-place. No
additional space is required.

I think I have to study the allocation because it's not clear to
me when to use it or not.

You use dynamic allocations only if you need the allocated memory
to outlive current scope block. Keep reading you favourite C++
textbook, it is explained there for sure.

I am convinced most of the things I am coding already exist and
have been optimized through the years. I like to try to code
them by myself for exercise.

This is always good way to learn new things.

HTH
Alex


.



Relevant Pages

  • Re: Altering Array Sizes within Functions
    ... > The function modifies the size and elements of myArray. ... If you use 'malloc' to allocate the array, ...
    (comp.lang.cpp)
  • Re: Cons cell archaic!?
    ... from s-expression or XML or other syntax you keep the bloated array ... For using vectors to emulate lists that ... Allocate 2, move 1 element: ... What do you think of that algorithm? ...
    (comp.lang.lisp)
  • Storing/Retrieving TYPEs with ALLOCATABLE components (TR) (long)
    ... tBrd, including array descriptor of tEn )). ... Without previous DEALLOCATE, the allocate line fails at run time with message ... the fact that I'm loading an invalid descriptor tBrd%tEn from the file... ... status (which is not possible according to Standard, but then BINARY files ...
    (comp.lang.fortran)
  • Re: Storing the size of an array in the structure itself
    ... >> I think every C programmer can relate to the frustrations that malloc ... >> the size of an array must be stored separately to be a nightmare. ... is anything more than just that - a chunk of memory. ... > Otherwise you couldn't tell it how much to allocate. ...
    (comp.lang.c)
  • determining available space for Float32, for instance
    ... I am looking for a way to determine the maxium array size I can allocate ... We do not want a solution that requires recompiling Python, ... agents may be households that choose a new gridcell to live in. ... Each attribute of a dataset has such a 2D array. ...
    (comp.lang.python)

Loading