I wants to change places in the arrays

http://i.hizliresim.com/1EN2DB.png

helpp!! case 2

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
cout << "Dizi boyutu: ";

int* psize = new int; // heap kullandigim yer
cin >> *psize;
cout << "Dizi basariyla olusturuldu.\n";


int secenek;
cout << endl << "Islemler" << endl;
cout << "1. Diziyi Yazdir" << endl;
cout << "2. Yer Degistir" << endl;
cout << "3. Cikis" << endl << ">> ";
cin >> secenek;

switch(secenek) {

case 1: {

for (int i = 0; i < *psize; i++)
{
cout << "[" << i << "] -> ";
cout << &psize+i << "\n";
}

delete psize;

}
break;

case 2: {








break;
}
case 3: {


break;
}



default: {
cout << "!! Listede verilen sayilari kullaniniz. !!\n";

}
}
}





Last edited on
closed account (DEhqDjzh)
you should use dynamic array https://www.youtube.com/watch?v=PocJ5jXv8No
Last edited on
Yes, I have difficulty even if I know it..
help!!!
The image looks like you want to swap memory locations. However, array is consecutive; no such swapping.

You can swap the values. std::swap( psize[3], psize[4] );
Java works differently from C++.

But you also need an container to store you values.
https://en.cppreference.com/w/cpp/container/vector

Something like this:
1
2
3
4
5
6
7
8
#include <iostream>
#include <vector>

int main()
{
    int size;
    std::cin >> size;
    std::vector<int> values(size);
Topic archived. No new replies allowed.