fork(1) download
  1. #include <iostream>
  2. #include <fstream>
  3. #include <iomanip>
  4. #include <string>
  5.  
  6. struct studentType
  7. {
  8.  
  9. string studentFName;
  10. string studentLName;
  11. int testScore;
  12. char grade;
  13.  
  14. };
  15.  
  16. void getData(ifstream & inFile, studentType sList [], int size);
  17. void calcGrade(studentType sList [], int size);
  18. int highScore(const studentType sList [], int size);
  19. void printOut(ofstream & outFile, const studentType sList [], int size);
  20.  
  21. void getData(ifstream & inFile, studentType sList [], int size)
  22. {
  23.  
  24. // inFile
  25.  
  26.  
  27. }
  28. int main()
  29. {
  30.  
  31. ifstream infile;
  32. ofstream outfile;
  33.  
  34. string inputFile;
  35. string outputFile;
  36. string firstname;
  37. string lastname;
  38. string variable;
  39.  
  40. studentType studentsArray[20];
  41.  
  42. infile.open("Ch11_Ex01Data.txt");
  43. outfile.open("test.txt");
  44.  
  45. if (!infile)
  46. {
  47. cout << "Cannot open the input file" << endl;
  48. return 1;
  49. system("pause");
  50. }
  51. infile >> firstname >> lastname;
  52. cout << firstname;
  53. cout << lastname;
  54. outfile << firstname << lastname;
  55. system("pause");
  56. cin >> variable;
  57. infile.close();
  58. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:9:2: error: ‘string’ does not name a type
  string studentFName;
  ^
prog.cpp:10:2: error: ‘string’ does not name a type
  string studentLName;
  ^
prog.cpp:16:14: error: variable or field ‘getData’ declared void
 void getData(ifstream & inFile, studentType sList [], int size);
              ^
prog.cpp:16:14: error: ‘ifstream’ was not declared in this scope
prog.cpp:16:14: note: suggested alternative:
In file included from /usr/include/c++/4.8/ios:38:0,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.8/iosfwd:157:34: note:   ‘std::ifstream’
   typedef basic_ifstream<char>   ifstream;
                                  ^
prog.cpp:16:25: error: ‘inFile’ was not declared in this scope
 void getData(ifstream & inFile, studentType sList [], int size);
                         ^
prog.cpp:16:45: error: expected primary-expression before ‘sList’
 void getData(ifstream & inFile, studentType sList [], int size);
                                             ^
prog.cpp:16:55: error: expected primary-expression before ‘int’
 void getData(ifstream & inFile, studentType sList [], int size);
                                                       ^
prog.cpp:19:15: error: variable or field ‘printOut’ declared void
 void printOut(ofstream & outFile, const studentType sList [], int size);
               ^
prog.cpp:19:15: error: ‘ofstream’ was not declared in this scope
prog.cpp:19:15: note: suggested alternative:
In file included from /usr/include/c++/4.8/ios:38:0,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.8/iosfwd:160:34: note:   ‘std::ofstream’
   typedef basic_ofstream<char>   ofstream;
                                  ^
prog.cpp:19:26: error: ‘outFile’ was not declared in this scope
 void printOut(ofstream & outFile, const studentType sList [], int size);
                          ^
prog.cpp:19:35: error: expected primary-expression before ‘const’
 void printOut(ofstream & outFile, const studentType sList [], int size);
                                   ^
prog.cpp:19:63: error: expected primary-expression before ‘int’
 void printOut(ofstream & outFile, const studentType sList [], int size);
                                                               ^
prog.cpp:21:14: error: variable or field ‘getData’ declared void
 void getData(ifstream & inFile, studentType sList [], int size)
              ^
prog.cpp:21:14: error: ‘ifstream’ was not declared in this scope
prog.cpp:21:14: note: suggested alternative:
In file included from /usr/include/c++/4.8/ios:38:0,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.8/iosfwd:157:34: note:   ‘std::ifstream’
   typedef basic_ifstream<char>   ifstream;
                                  ^
prog.cpp:21:25: error: ‘inFile’ was not declared in this scope
 void getData(ifstream & inFile, studentType sList [], int size)
                         ^
prog.cpp:21:45: error: expected primary-expression before ‘sList’
 void getData(ifstream & inFile, studentType sList [], int size)
                                             ^
prog.cpp:21:55: error: expected primary-expression before ‘int’
 void getData(ifstream & inFile, studentType sList [], int size)
                                                       ^
prog.cpp: In function ‘int main()’:
prog.cpp:31:2: error: ‘ifstream’ was not declared in this scope
  ifstream infile;
  ^
prog.cpp:31:2: note: suggested alternative:
In file included from /usr/include/c++/4.8/ios:38:0,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.8/iosfwd:157:34: note:   ‘std::ifstream’
   typedef basic_ifstream<char>   ifstream;
                                  ^
prog.cpp:31:11: error: expected ‘;’ before ‘infile’
  ifstream infile;
           ^
prog.cpp:32:2: error: ‘ofstream’ was not declared in this scope
  ofstream outfile;
  ^
prog.cpp:32:2: note: suggested alternative:
In file included from /usr/include/c++/4.8/ios:38:0,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.8/iosfwd:160:34: note:   ‘std::ofstream’
   typedef basic_ofstream<char>   ofstream;
                                  ^
prog.cpp:32:11: error: expected ‘;’ before ‘outfile’
  ofstream outfile;
           ^
prog.cpp:34:2: error: ‘string’ was not declared in this scope
  string inputFile;
  ^
prog.cpp:34:2: note: suggested alternative:
In file included from /usr/include/c++/4.8/iosfwd:39:0,
                 from /usr/include/c++/4.8/ios:38,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/4.8/bits/stringfwd.h:62:33: note:   ‘std::string’
   typedef basic_string<char>    string;   
                                 ^
prog.cpp:34:9: error: expected ‘;’ before ‘inputFile’
  string inputFile;
         ^
prog.cpp:35:9: error: expected ‘;’ before ‘outputFile’
  string outputFile;
         ^
prog.cpp:36:9: error: expected ‘;’ before ‘firstname’
  string firstname;
         ^
prog.cpp:37:9: error: expected ‘;’ before ‘lastname’
  string lastname;
         ^
prog.cpp:38:9: error: expected ‘;’ before ‘variable’
  string variable;
         ^
prog.cpp:42:2: error: ‘infile’ was not declared in this scope
  infile.open("Ch11_Ex01Data.txt");
  ^
prog.cpp:43:2: error: ‘outfile’ was not declared in this scope
  outfile.open("test.txt");
  ^
prog.cpp:47:3: error: ‘cout’ was not declared in this scope
   cout << "Cannot open the input file" << endl; 
   ^
prog.cpp:47:3: note: suggested alternative:
In file included from prog.cpp:1:0:
/usr/include/c++/4.8/iostream:61:18: note:   ‘std::cout’
   extern ostream cout;  /// Linked to standard output
                  ^
prog.cpp:47:43: error: ‘endl’ was not declared in this scope
   cout << "Cannot open the input file" << endl; 
                                           ^
prog.cpp:47:43: note: suggested alternative:
In file included from /usr/include/c++/4.8/iostream:39:0,
                 from prog.cpp:1:
/usr/include/c++/4.8/ostream:564:5: note:   ‘std::endl’
     endl(basic_ostream<_CharT, _Traits>& __os)
     ^
prog.cpp:49:17: error: ‘system’ was not declared in this scope
   system("pause");
                 ^
prog.cpp:51:12: error: ‘firstname’ was not declared in this scope
  infile >> firstname >> lastname;
            ^
prog.cpp:51:25: error: ‘lastname’ was not declared in this scope
  infile >> firstname >> lastname;
                         ^
prog.cpp:52:2: error: ‘cout’ was not declared in this scope
  cout << firstname;
  ^
prog.cpp:52:2: note: suggested alternative:
In file included from prog.cpp:1:0:
/usr/include/c++/4.8/iostream:61:18: note:   ‘std::cout’
   extern ostream cout;  /// Linked to standard output
                  ^
prog.cpp:55:16: error: ‘system’ was not declared in this scope
  system("pause");
                ^
prog.cpp:56:2: error: ‘cin’ was not declared in this scope
  cin >> variable;
  ^
prog.cpp:56:2: note: suggested alternative:
In file included from prog.cpp:1:0:
/usr/include/c++/4.8/iostream:60:18: note:   ‘std::cin’
   extern istream cin;  /// Linked to standard input
                  ^
prog.cpp:56:9: error: ‘variable’ was not declared in this scope
  cin >> variable;
         ^
prog.cpp:40:14: warning: unused variable ‘studentsArray’ [-Wunused-variable]
  studentType studentsArray[20];
              ^
stdout
Standard output is empty