fork download
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. typedef struct Node {
  5. int nr;
  6. int num;
  7. } Node;
  8.  
  9. typedef struct Node2 {
  10. char name[50];
  11. int code;
  12. } Node2;
  13.  
  14.  
  15. int main(int argc, char const *argv[]) {
  16.  
  17. Node *s;
  18. Node2 *s2;
  19. s = new Node[100];
  20. s2 = new Node2[100];
  21.  
  22. s[0] = {1,2};
  23. s[1] = {3,4};
  24.  
  25.  
  26. std::cout<<s[0].nr<<"-"<<s[0].num<<"\n";
  27. std::cout<<s[1].nr<<"-"<<s[1].num<<"\n";
  28.  
  29.  
  30. strcpy(s2[0].name, "Ubuntu");
  31. s2[0].code = 1;
  32.  
  33. strcpy(s2[1].name, "Debian");
  34. s2[1].code = 2;
  35.  
  36.  
  37. std::cout<<s2[0].name<<"-"<<s2[0].code<<"\n";
  38. std::cout<<s2[1].name<<"-"<<s2[1].code<<"\n";
  39.  
  40.  
  41. delete [] s;
  42. delete [] s2;
  43.  
  44. return 0;
  45. }
  46.  
Success #stdin #stdout 0.01s 5432KB
stdin
Standard input is empty
stdout
1-2
3-4
Ubuntu-1
Debian-2