fork download
  1. // CSC 234 Project 1.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <iomanip>
  7. #include <string>
  8. #include <fstream>
  9.  
  10. using namespace std;
  11.  
  12. void classArray(string studentNames[], int size);
  13.  
  14. int main()
  15. {
  16. const int SIZE = 4;
  17.  
  18. string students[SIZE];
  19.  
  20. classArray(students, SIZE);
  21.  
  22. return 0;
  23. }
  24.  
  25. void classArray(string studentNames[], int size)
  26. {
  27. const int ROWS = 4;
  28. const int COLS = 4;
  29.  
  30. int studentGrades[ROWS][COLS];
  31.  
  32. ifstream inputFile;
  33.  
  34. inputFile.open("StudentNames.txt");
  35.  
  36. while (!inputFile.eof())
  37. {
  38. for (int i = 0; i < size; ++i)
  39. {
  40. inputFile >> studentNames[i];
  41. }
  42. }
  43.  
  44. ifstream inputFile2;
  45.  
  46. inputFile2.open("Grades.txt");
  47.  
  48. while (!inputFile2.eof())
  49. {
  50. for (int i = 0; i < ROWS; ++i)
  51. {
  52. for (int j = 0; j < COLS - 1; ++j)
  53. {
  54. inputFile2 >> studentGrades[i][j];
  55. }
  56. }
  57. }
  58.  
  59. for (int i = 0; i < size; ++i)
  60. {
  61. for (int j = 0; j < ROWS; ++j)
  62. {
  63. cout << studentNames[i] << " " << studentGrades[i][j] << endl;
  64. }
  65. }
  66.  
  67. inputFile2.close();
  68. inputFile.close();
  69. }
  70.  
  71. /*void classArray()
  72. {
  73. const int SIZE = 4;
  74.  
  75. string studentNames[SIZE];
  76.  
  77. ifstream inputFile;
  78.  
  79. inputFile.open("StudentNames.txt");
  80.  
  81. while (!inputFile.eof())
  82. {
  83. for (int i = 0; i < SIZE; ++i)
  84. {
  85. inputFile >> studentNames[i];
  86. cout << studentNames[i] << " ";
  87. }
  88. }
  89.  
  90. cout << endl;
  91. inputFile.close();
  92. }*/
  93.  
  94.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(5,0): error CS1024: Wrong preprocessor directive
prog.cs(6,0): error CS1024: Wrong preprocessor directive
prog.cs(7,0): error CS1024: Wrong preprocessor directive
prog.cs(8,0): error CS1024: Wrong preprocessor directive
prog.cs(9,0): error CS1024: Wrong preprocessor directive
prog.cs(10,6): error CS1525: Unexpected symbol `namespace', expecting `identifier' or `static'
prog.cs(10,19): error CS1525: Unexpected symbol `;', expecting `identifier' or `static'
prog.cs(12,36): error CS1514: Unexpected symbol `[', expecting `.' or `{'
prog.cs(12,36): error CS1525: Unexpected symbol `]', expecting `identifier' or `static'
prog.cs(18,22): error CS1525: Unexpected symbol `;'
Compilation failed: 10 error(s), 0 warnings
stdout
Standard output is empty