everton Posted February 23, 2010 Report Posted February 23, 2010 cum pot face cu cout sa vad locatia unei variabile in memorie cu printf se folosea & dar dak dau cu cout de ex: cout<<&variabila imi apar doar prostiidar daca dau de exemplu : int main(){ char a[2],b[2]; cout<<&a<<"\n"; cout<<&b; getch(); return 0;} atunci imi apare locatia in memorie Quote
loki Posted February 24, 2010 Report Posted February 24, 2010 Care e problema, ce prostii iti apar?0xbf9543fe e ok, e in hexa. (32bit compilat cu bcc32)0xfff4 e ok (16 bit, compilat cu bcc)& nu se folosea din cauza printf ci se foloseste intotdeauna in C pentru adresa variabilelor.Nu iti va afisa niciodata adresa reala, ci adresa in segmentul de memorie in care isi memoreaza datele. Quote
everton Posted February 24, 2010 Author Report Posted February 24, 2010 imi apar prosti gen mere inimioare si alte caractere Quote
cmiN Posted February 24, 2010 Report Posted February 24, 2010 #include <iostream>using namespace std;int main(){ unsigned long x, y[10]; x = 4; y[0] = 0; y[1] = 1; cout << x << " " << &x << " " << int(&x); cout << "\n"; cout << y << " " << &y; // cu sau fara & e tot aia ca y e pointer cout << " " << &y[0]; system("pause >NUL"); return 0;}Foloseste int(&var) pentru a vedea valoarea respectiva in baza 10, prin prostie cum zicea si loki cred ca te referi ca ti-o arata in baza 16.EDIT:Inseamna ca iti face char() de ceva care este >127. Quote
loki Posted February 24, 2010 Report Posted February 24, 2010 ciudat, ori e diferenta de compilator ori tu de fapt ai alt program in fata.cout<<a<<"\n"; cred ca ti-ar putea da un asemenea rezultat aiurea atat timp cat tu nu ai pus valori in a[] si b[]. Iti afiseaza date la intamplare gasite in memorie. Quote