Advertisement
AntonioVillanueva

for auto struct

Apr 8th, 2016
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {  
  6.     struct s {int x, y;char c;}; //se define una struct
  7.  
  8.     s matriz[] { {1,2,'a'},{3,4,'b'},{5,6,'c'} };// y un array de structs
  9.    
  10.     for (auto y : matriz ){//uso de auto con un array de struct s
  11.         cout<<y.x<<" , "<<y.y<< " , "<<y.c<<endl;      
  12.     }
  13.    
  14.     return 0;  
  15.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement