Mihail
Could you help me please what is my mistake
int temp; should be a int *temp;
Mihail
And I don't think you should be dereferencing them when doing that swap
Anonymous
Mihail
Read the message below
Mihail
If it again doesn't work can you paste the new code in a pastebin?
Anonymous
It is an exercise from a book, I should not change the function names and parameters
Mihail
I haven't told you to change those
Mihail
Here inside the function why are you dereferencing the pointers?
Anonymous
I dont understand. since they are pointers, shouldnt I dereference them
Anonymous
I guess I found the problem
Anonymous
I should call the swap function like this: swap(&array[j], &array[j+1]);
BinaryByter
you shall?
Anonymous
Now it prints everything properly, but sorting is wrong :D
Anonymous
I’ll ask my teacher tomorrrow, thank you guys...
olli
Could you help me please what is my mistake
you access elements outside of the array. j goes from 0 to size-1, since you compare j and j+1 you access the indices size - 1 and size.
Anonymous
I arranged it, still doesnt work correctly
Anonymous
i<size-1 and j<size-1 this is how it should be, correct?
olli
i<size-1 and j<size-1 this is how it should be, correct?
yes, although you don't need to change i since it does not affect the index
Anonymous
Okay thanks
olli
and in swap
olli
Here inside the function why are you dereferencing the pointers?
you should do *ptr2 = temp; in the end, since you change *ptr1 already
Anonymous
Omg
Anonymous
What a stupid mistake :D
Anonymous
It works now, thank you so much...
Mihail
you should do *ptr2 = temp; in the end, since you change *ptr1 already
Shouldn't he be doing ptr1 = ptr2; without dereferencing the second one or am I dumb?
olli
It works now, thank you so much...
sure :) glad it works 👍🏻
Anonymous
You are right, I am a dumb...
olli
Shouldn't he be doing ptr1 = ptr2; without dereferencing the second one or am I dumb?
but changes to the pointers are only visible inside the function, you want to change the values
Anonymous
im looking for someone to help me thru c++
Anonymous
hey, is the sentence "Gets the items' count" right? I don't speak english and i don't know. I want it for the documentation, and haven't seen any same sentence by anyone while searching. sorry i'm asking here.
Anonymous
i mean the grammar
olli
items without "'" ? haven't found :D
e.g https://github.com/msgpack/msgpack-cli/blob/master/src/MsgPack/Serialization/UnpackHelpers.cs#L644
Anonymous
so what is technically right 😶
Anonymous
i'm so obssesed..
Anonymous
e.g https://github.com/msgpack/msgpack-cli/blob/master/src/MsgPack/Serialization/UnpackHelpers.cs#L644
so that's a function name, i'm searching for the english sentence
olli
like this?
Anonymous
oh well thanks! 😁 you're so active btw
Anonymous
but, is it wrong if i type "items' count" ?
olli
I think grammar wise using ' is fine as well.. although I'm not a native english speaker
Nehemiah Aklil
hi coders
Nehemiah Aklil
I have a qsn should I install Visual studio commutinty version or Visual studio 2010 ultimate veriosn
Nicola
good evening, does anyone know how to exchange the order of an array and save the initial position to go back to the old order?
olli
I have a qsn should I install Visual studio commutinty version or Visual studio 2010 ultimate veriosn
Depends on what you need .. I would go with the latest version (C++17 support, ...)
Nicola
For example 123456789 -> 952713486
Nehemiah Aklil
Depends on what you need .. I would go with the latest version (C++17 support, ...)
17 is huge and the specs are too much form my little boy😕
Nicola
I exchange the position of the array and save the initial position for going back to the old order
Anonymous
save the changes? why?
Anonymous
Ctrl+Z?
Anonymous
like swapped_items.push_back(pair(index1, index2));?
olli
No
Then add more context please. Why would a copy not suffice? Either use a list to store or a map to project the changes made. If you are going to change most of the items copying the array might still be faster. Depending on the implementation reverting can be done in O(1)
Nikk
Yes I am human
Aspire
Double x, int y, int z x /=z y/= z Return x+y x is 9, y is 14, z is 4 I got the ans 5.25 Buht when i solve this on calculator the comes 5.75 Why the ans is not same in c++
Aspire
It comes*
olli
Double x, int y, int z x /=z y/= z Return x+y x is 9, y is 14, z is 4 I got the ans 5.25 Buht when i solve this on calculator the comes 5.75 Why the ans is not same in c++
what's your code? above y and z are integral values, hence the result of the division of y/z is integral (3 instead of 3.5)
Heenim
can somebody help me with this? https://github.com/akodorayaki/hanim/blob/master/README.md
Heenim
last monday it's work just fine.. but it's started to make a problem on tuesday. i didn't even change the code.
Heenim
We have arduino room?
Heenim
It keep showing the authorize token for Blynk app instead of the sensor's value
Aspire
What is formula of squareArea??
olli
What is formula of squareArea??
a^2 (where a is length of the side)
Aspire
That mean height * width ??
olli
Yes, since the sides of a square have the same length it's you can take the square of it
Aspire
Ok
Anonymous
How can I use the Object Oriented C (ooc) toolkit?
Anonymous
I have following *.h files,
Anonymous
Anonymous
when i execute the code
Anonymous
/#include <stdio.h> #include <ooc/ooc.h> DeclareClass(String1, Base); ClassMembers(String1, Base) char * cstr; EndOfClassMembers; typedef struct String1Params { const char *cstr; } String1Params; int main() { ooc_init_class(String1); int i = 0; printf("%d", i); }/