ToniDev

Struct Masina

Mar 23rd, 2022
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. struct Masina
  6. {
  7.     char marca[20] = "";
  8.     char culoare[20] = "";
  9.     int cai_putere;
  10.    
  11. } m1, m2;
  12.  
  13. int main()
  14. {
  15.     strcpy(m1.marca, "Audi");
  16.     strcpy(m1.culoare, "Negru");
  17.     m1.cai_putere = 400;
  18.    
  19.     strcpy(m2.marca, "Opel");
  20.     strcpy(m2.culoare, "Alb");
  21.     m2.cai_putere = 300;
  22.    
  23.     cout << m1.marca << endl;
  24.     cout << m1.culoare << endl;
  25.     cout << m1.cai_putere << endl << endl;
  26.    
  27.     cout << m2.marca << endl;
  28.     cout << m2.culoare << endl;
  29.     cout << m2.cai_putere << endl;
  30.    
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment