Created
September 25, 2019 19:41
-
-
Save FDSoftware/4f98c41f0f1a7243053a4865ec70eb59 to your computer and use it in GitHub Desktop.
test de punteros y punteros sobre punteros, confuso a mas no poder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
// udp es el ultimo digito del padron | |
int udp = 8; | |
int *f1 (int cant){ | |
int *aux = new int[cant]; | |
return aux; | |
} | |
void f2 (int **p, int a){ | |
*p = new int; | |
**p = a--; | |
cout << **p << (char)a << endl; | |
} | |
void f3 (int *&r, int *q){ | |
r = q + 1; | |
} | |
int main(){ | |
int cant = (udp % 3) + 2; // udp es el ultimo digito del padron | |
int *x, *y, *z; | |
char a = 'A';/* Nota: 'A' es 65 */ | |
x = f1(cant); | |
for (int i = 0; i < cant; i++) | |
x[i] = a + i; | |
f2(&y, a + cant); | |
cout << *y << *x << endl; | |
f3(z, x); | |
cout << *z << endl; | |
*z = *x + 2; | |
cout << *z << *(x + 1) << *y << endl; | |
z = y; | |
a = (char)(*y); | |
f3(y, x); | |
cout << *y << a << *z << x[1] << endl; | |
for (int i = 0; i < cant; i++) | |
cout << *(x + i) << endl; | |
// Instrucciones para liberar la memoria | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment