neogz

strukture, inicijalizacija ispis

Apr 3rd, 2014
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct torte {
  5.     char naziv[20];
  6.     float cijena;
  7.     char narucio[20];
  8. };
  9.  
  10. int main()
  11. {  
  12.     // inicijalizacija varijable torta1, sa atributima naziv, cijena, narucio
  13.     torte torta1;
  14.  
  15.     // atribudi objekta torta1
  16.     strcpy_s(torta1.naziv, "Monte");
  17.     torta1.cijena = 30;
  18.     strcpy_s(torta1.narucio, "Muris Zivojevic");
  19.  
  20.     torte torta2;
  21.     torta2 = { "Crnac sa jajima", 50, "Amer Rafa Halilovic" };
  22.  
  23.     // ispis
  24.  
  25.     cout << "Torta 1\n__________________________________\n";
  26.     cout << "Naziv torte: \t\t"<< torta1.naziv << endl;
  27.     cout << "Cijena torte: \t\t" << torta1.cijena << " KM"<< endl;
  28.     cout << "Narucioc torte: \t" << torta1.narucio << endl<<endl<<endl;
  29.  
  30.     cout << "Torta 2\n__________________________________\n";
  31.     cout << "Naziv torte: \t\t" << torta2.naziv << endl;
  32.     cout << "Cijena torte: \t\t" << torta2.cijena << " KM" << endl;
  33.     cout << "Narucioc torte: \t" << torta2.narucio << endl;
  34.  
  35.  
  36.  
  37.  
  38.     system("pause >nul");
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment