Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #define t *tt //Pas trop elegante mais ...
- using namespace std;
- int tableau[1000];
- int nulo;
- int* tt(int ind){
- if (ind<0 || ind>999){cout<<"Erreur index="<<ind<<endl;return &nulo;}
- if (tableau[1000]==0){//Initialise valeurs.....
- tableau[6]=8;//Pour tester if (t(6) == 8)
- tableau[1000]=1;
- }
- return &tableau[ind];
- }
- int main(){
- cout <<t(3)<<endl;//Test t(3) avant
- t(3) = 5;
- cout <<t(3)<<endl;//Test t(3) apres
- cout <<t(6)<<endl;//Test *t(6) == 8
- if (t(6) == 8) {t(6) = t(4);}
- cout <<t(6)<<endl;//Test *t(6) == *t(4)
- t(1000) = 3; // Affichage d'une Erreur
- t(-1) = 2; // Affichage d'une Erreur
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement