fork download
  1.  
  2. #include <iomanip>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. struct NOTE {
  8. char name[10];
  9. char surname[15];
  10. int date_of_birthday[3];
  11. double salary;
  12. };
  13.  
  14. void show(const int size, int* pmatrix); // show matrix
  15.  
  16. void show(NOTE* pstruct); // show structure
  17.  
  18.  
  19. int main()
  20. {
  21. const int size = 3;
  22. int matrix[size][size] = { {1, 7, 4},
  23. {2, 2, 8},
  24. {9, 9, 4} };
  25.  
  26. int* pmatrix = &matrix[0][0];
  27.  
  28. show(size, pmatrix);
  29.  
  30. NOTE structure;
  31. structure.name = "2";
  32.  
  33. NOTE* pstruct = &structure;
  34. }
  35.  
  36. void show(const int size, int* pmatrix) // show matrix
  37. {
  38. for (int i = 0; i < size*size; i++)
  39. {
  40. if ((i % size == 0) && (i != 0))
  41. {
  42. cout << '\n' << *(pmatrix + i);
  43. }
  44.  
  45. else
  46. {
  47. cout << *(pmatrix + i);
  48. }
  49. }
  50. }
  51.  
  52. void show(NOTE* pstruct) // show structure
  53. {
  54. cout << setw(10) << "Name: " << setw(15) << pstruct->name << " | " << "\t";
  55. cout << setw(10) << "Surname: " << setw(15) << pstruct->surname << " | " << "\t";
  56. cout << setw(10) << "Date of birthday: ";
  57. for (int j = 0; j < 3; j++) {
  58. cout << setw(4) << pstruct->date_of_birthday[j] << " ";;
  59. if (j == 2) cout << " | ";
  60. };
  61. cout << setw(10) << "Salary: " << pstruct->salary << endl;
  62.  
  63. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:31:22: error: incompatible types in assignment of ‘const char [2]’ to ‘char [10]’
     structure.name = "2";
                      ^~~
stdout
Standard output is empty