[nfbcs] Failing If Statement

Lanie Molinar laniemolinar91 at gmail.com
Fri Oct 27 19:20:19 UTC 2017


Hi. I was getting two error messages during one of the tests my school's 
testbed program ran, so I tried to fix it, and I'm now getting some 
results I never expected. Is my redesigned if statement toward the 
bottom of the readFile function not right?


On 10/27/2017 1:11 PM, Mike Gorse wrote:
> Hi Lanie,
>
> I'm guessing that these lines are what you're referring to:
>
>    if (fin.fail());
>       cout << "Error reading file \"" << fileName << "\"\n";
>
> You have a ; at the end of the if clause. You don't want a ; at the 
> end of the line; it will make the if clause do nothing, and the 
> following line will be executed unconditionally.
>
> If you pass -Wall to g++, then it will print a warning (or at least it 
> will with the version that I have installed).
>
> Hth,
> -Mike
>
> On Fri, 27 Oct 2017, Lanie Molinar via nfbcs wrote:
>
>> Hi, everyone. Thanks for your help again last night. If you don't 
>> mind, I have another question. I'm working on another assignment and 
>> have almost everything worked out, but one of my if statements is 
>> acting weird, and I can't figure out why. It's reporting an error 
>> when it shouldn't be. I've gone over my code several times, and 
>> everything seems fine to me. Can someone please take a look? The 
>> grades.txt file I attached is used by my program. Thanks.
>>
>>

-------------- next part --------------
/***********************************************************************
* Program:
*    Assignment 26, Files
*    Sister Unsicker, CS124
* Author:
*    Lanie Molinar
* Summary: 
*    This program reads 10 grades from a file and then displays the average.
*
*    Estimated:  1.0 hrs   
*    Actual:     4.0 hrs
*      I kept getting errors when I tried to compile my program and couldn't 
*      figure out why until I read some threads on the developers' forum and 
*      found one posted by someone with the same problem. It turns out that I
*      was putting brackets in my function calls when I shouldn't have been.
************************************************************************/

#include <iostream>
#include <fstream>
using namespace std;

/***********************************************************************
* This function prompts the user for the name of the file that contains their
* grades and then passes it to main.
***********************************************************************/
void getFileName(char fileName[])
{
   cout << "Please enter the filename: ";
   cin >> fileName;
}

/***********************************************************************
* This function reads the grades file and averages the numbers in it if there
* are 10 of them, outputting an error if there are not.
***********************************************************************/
float readFile(char fileName[])
{
   ifstream fin(fileName);
   if (fin.fail())
      cout << "Error reading file \"" << fileName << "\"\n";
   float grade;
   int numGrades = 0;
   float sum = 0.0;
   while (fin >> grade)
   {
      numGrades++;
      sum += grade;
   }
   if ((numGrades != 10) && (fin.fail() == false))
   {
      cout << "Error reading file \"" << fileName << "\"\n";
      fin.close();
      return 0.0;
   }
   else
   {
      fin.close();
      return (sum / numGrades);
   }
}

/***********************************************************************
* This function displays the average that was computed in the readFile() 
* function.
***********************************************************************/
void display(float average)
{
   cout.setf(ios::fixed);
   cout.precision(0);
   if (average != 0.0)
      cout << "Average Grade: " << average << "%\n";
}

/**********************************************************************
*    The main function calls the other functions annd passes data between 
*    them.
***********************************************************************/
int main()
{
   char fileName[256];
   getFileName(fileName);
   float average = readFile(fileName);
   display(average);
   return 0;
}
-------------- next part --------------
=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2017.10.27 11:17:47 =~=~=~=~=~=~=~=~=~=~=~=
Using username "living4god1991".
living4god1991 at 157.201.194.201's password: 
Last login: Fri Oct 27 01:10:27 2017 from 67.44.193.75

[living4god1991 at LinuxLab01 ~]$ g++ assignment26.cpp
assignment26.cpp:21:41: warning: missing terminating " character [enabled by default]
    cout << "Please" enter the filename: ";
                                         ^
assignment26.cpp:21:4: error: missing terminating " character
    cout << "Please" enter the filename: ";
    ^
assignment26.cpp: In function void getFileName(char*):
assignment26.cpp:21:21: error: expected ; before enter
    cout << "Please" enter the filename: ";
                     ^
assignment26.cpp: In function float readFile(const char*):
assignment26.cpp:38:13: error: statement cannot resolve address of overloaded function
    fin.close;
             ^
assignment26.cpp: In function void display(float):
assignment26.cpp:51:4: error: expected ; before cout
    cout.precision(2)
    ^
assignment26.cpp: In function int main():
assignment26.cpp:60:45: error: array must be initialized with a brace-enclosed initializer
    char fileName[256] = getFileName(fileName);
                                             ^
[living4god1991 at LinuxLab01 ~]$ g++ assignment26.cpp
assignment26.cpp: In function void getFileName(const char*):
assignment26.cpp:22:8: error: no match for operator>> (operand types are std::istream {aka std::basic_istream<char>} and const char*)
    cin >> fileName;
        ^
assignment26.cpp:22:8: note: candidates are:
In file included from /usr/include/c++/4.8.2/iostream:40:0,
                 from assignment26.cpp:15:
/usr/include/c++/4.8.2/istream:120:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__istream_type& (*)(std::basic_istream<_CharT, _Traits>::__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(__istream_type& (*__pf)(__istream_type&))
       ^
/usr/include/c++/4.8.2/istream:120:7: note:   no known conversion for argument 1 from const char* to std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&) {aka std::basic_istream<char>& (*)(std::basic_istream<char>&)}
/usr/include/c++/4.8.2/istream:124:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__ios_type& (*)(std::basic_istream<_CharT, _Traits>::__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>; std::basic_istream<_CharT, _Traits>::__ios_type = std::basic_ios<char>]
       operator>>(__ios_type& (*__pf)(__ios_type&))
       ^
/usr/include/c++/4.8.2/istream:124:7: note:   no known conversion for argument 1 from const char* to std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&) {aka std::basic_ios<char>& (*)(std::basic_ios<char>&)}
/usr/include/c++/4.8.2/istream:131:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(ios_base& (*__pf)(ios_base&))
       ^
/usr/include/c++/4.8.2/istream:131:7: note:   no known conversion for argument 1 from const char* to std::ios_base& (*)(std::ios_base&)
/usr/include/c++/4.8.2/istream:168:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(bool& __n)
       ^
/usr/include/c++/4.8.2/istream:168:7: note:   no known conversion for argument 1 from const char* to bool&
/usr/include/c++/4.8.2/istream:172:7: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]
       operator>>(short& __n);
       ^
/usr/include/c++/4.8.2/istream:172:7: note:   no known conversion for argument 1 from const char* to short int&
/usr/include/c++/4.8.2/istream:175:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(unsigned short& __n)
       ^
/usr/include/c++/4.8.2/istream:175:7: note:   no known conversion for argument 1 from const char* to short unsigned int&
/usr/include/c++/4.8.2/istream:179:7: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]
       operator>>(int& __n);
       ^
/usr/include/c++/4.8.2/istream:179:7: note:   no known conversion for argument 1 from const char* to int&
/usr/include/c++/4.8.2/istream:182:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(unsigned int& __n)
       ^
/usr/include/c++/4.8.2/istream:182:7: note:   no known conversion for argument 1 from const char* to unsigned int&
/usr/include/c++/4.8.2/istream:186:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(long& __n)
       ^
/usr/include/c++/4.8.2/istream:186:7: note:   no known conversion for argument 1 from const char* to long int&
/usr/include/c++/4.8.2/istream:190:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(unsigned long& __n)
       ^
/usr/include/c++/4.8.2/istream:190:7: note:   no known conversion for argument 1 from const char* to long unsigned int&
/usr/include/c++/4.8.2/istream:195:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(long long& __n)
       ^
/usr/include/c++/4.8.2/istream:195:7: note:   no known conversion for argument 1 from const char* to long long int&
/usr/include/c++/4.8.2/istream:199:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(unsigned long long& __n)
       ^
/usr/include/c++/4.8.2/istream:199:7: note:   no known conversion for argument 1 from const char* to long long unsigned int&
/usr/include/c++/4.8.2/istream:214:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(float& __f)
       ^
/usr/include/c++/4.8.2/istream:214:7: note:   no known conversion for argument 1 from const char* to float&
/usr/include/c++/4.8.2/istream:218:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(double& __f)
       ^
/usr/include/c++/4.8.2/istream:218:7: note:   no known conversion for argument 1 from const char* to double&
/usr/include/c++/4.8.2/istream:222:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(long double& __f)
       ^
/usr/include/c++/4.8.2/istream:222:7: note:   no known conversion for argument 1 from const char* to long double&
/usr/include/c++/4.8.2/istream:235:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(void*& __p)
       ^
/usr/include/c++/4.8.2/istream:235:7: note:   no known conversion for argument 1 from const char* to void*&
/usr/include/c++/4.8.2/istream:259:7: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__streambuf_type*) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf<char>]
       operator>>(__streambuf_type* __sb);
       ^
/usr/include/c++/4.8.2/istream:259:7: note:   no known conversion for argument 1 from const char* to std::basic_istream<char>::__streambuf_type* {aka std::basic_streambuf<char>*}
In file included from /usr/include/c++/4.8.2/string:53:0,
                 from /usr/include/c++/4.8.2/bits/locale_classes.h:40,
                 from /usr/include/c++/4.8.2/bits/ios_base.h:41,
                 from /usr/include/c++/4.8.2/ios:42,
                 from /usr/include/c++/4.8.2/ostream:38,
                 from /usr/include/c++/4.8.2/iostream:39,
                 from assignment26.cpp:15:
/usr/include/c++/4.8.2/bits/basic_string.tcc:996:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::basic_string<_CharT, _Traits, _Alloc>&)
     operator>>(basic_istream<_CharT, _Traits>& __in,
     ^
/usr/include/c++/4.8.2/bits/basic_string.tcc:996:5: note:   template argument deduction/substitution failed:
assignment26.cpp:22:11: note:   mismatched types std::basic_string<_CharT, _Traits, _Alloc> and const char*
    cin >> fileName;
           ^
In file included from /usr/include/c++/4.8.2/istream:882:0,
                 from /usr/include/c++/4.8.2/iostream:40,
                 from assignment26.cpp:15:
/usr/include/c++/4.8.2/bits/istream.tcc:955:5: note: template<class _CharT2, class _Traits2> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, _CharT2*)
     operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s)
     ^
/usr/include/c++/4.8.2/bits/istream.tcc:955:5: note:   template argument deduction/substitution failed:
assignment26.cpp:22:11: note:   deduced conflicting types for parameter _CharT2 (char and const char)
    cin >> fileName;
           ^
In file included from /usr/include/c++/4.8.2/istream:882:0,
                 from /usr/include/c++/4.8.2/iostream:40,
                 from assignment26.cpp:15:
/usr/include/c++/4.8.2/bits/istream.tcc:923:5: note: template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, _CharT&)
     operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c)
     ^
/usr/include/c++/4.8.2/bits/istream.tcc:923:5: note:   template argument deduction/substitution failed:
assignment26.cpp:22:11: note:   deduced conflicting types for parameter _CharT (char and const char*)
    cin >> fileName;
           ^
In file included from /usr/include/c++/4.8.2/iostream:40:0,
                 from assignment26.cpp:15:
/usr/include/c++/4.8.2/istream:727:5: note: template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char&)
     operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
     ^
/usr/include/c++/4.8.2/istream:727:5: note:   template argument deduction/substitution failed:
assignment26.cpp:22:11: note:   cannot convert fileName (type const char*) to type unsigned char&
    cin >> fileName;
           ^
In file included from /usr/include/c++/4.8.2/iostream:40:0,
                 from assignment26.cpp:15:
/usr/include/c++/4.8.2/istream:732:5: note: template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char&)
     operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
     ^
/usr/include/c++/4.8.2/istream:732:5: note:   template argument deduction/substitution failed:
assignment26.cpp:22:11: note:   cannot convert fileName (type const char*) to type signed char&
    cin >> fileName;
           ^
In file included from /usr/include/c++/4.8.2/iostream:40:0,
                 from assignment26.cpp:15:
/usr/include/c++/4.8.2/istream:774:5: note: template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char*)
     operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s)
     ^
/usr/include/c++/4.8.2/istream:774:5: note:   template argument deduction/substitution failed:
assignment26.cpp:22:11: note:   cannot convert fileName (type const char*) to type unsigned char*
    cin >> fileName;
           ^
In file included from /usr/include/c++/4.8.2/iostream:40:0,
                 from assignment26.cpp:15:
/usr/include/c++/4.8.2/istream:779:5: note: template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char*)
     operator>>(basic_istream<char, _Traits>& __in, signed char* __s)
     ^
/usr/include/c++/4.8.2/istream:779:5: note:   template argument deduction/substitution failed:
assignment26.cpp:22:11: note:   cannot convert fileName (type const char*) to type signed char*
    cin >> fileName;
           ^
assignment26.cpp: In function float readFile(const char*):
assignment26.cpp:38:13: error: statement cannot resolve address of overloaded function
    fin.close;
             ^
assignment26.cpp: In function int main():
assignment26.cpp:60:46: error: expected primary-expression before ] token
    char fileName[256] = getFileName(fileName[]);
                                              ^
assignment26.cpp:61:38: error: expected primary-expression before ] token
    float average = readFile(fileName[]);
                                      ^
[living4god1991 at LinuxLab01 ~]$ g++ assignment26.cpp
assignment26.cpp: In function void getFileName(const char*):
assignment26.cpp:22:8: error: no match for operator>> (operand types are std::istream {aka std::basic_istream<char>} and const char*)
    cin >> fileName;
        ^
assignment26.cpp:22:8: note: candidates are:
In file included from /usr/include/c++/4.8.2/iostream:40:0,
                 from assignment26.cpp:15:
/usr/include/c++/4.8.2/istream:120:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__istream_type& (*)(std::basic_istream<_CharT, _Traits>::__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(__istream_type& (*__pf)(__istream_type&))
       ^
/usr/include/c++/4.8.2/istream:120:7: note:   no known conversion for argument 1 from const char* to std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&) {aka std::basic_istream<char>& (*)(std::basic_istream<char>&)}
/usr/include/c++/4.8.2/istream:124:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__ios_type& (*)(std::basic_istream<_CharT, _Traits>::__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>; std::basic_istream<_CharT, _Traits>::__ios_type = std::basic_ios<char>]
       operator>>(__ios_type& (*__pf)(__ios_type&))
       ^
/usr/include/c++/4.8.2/istream:124:7: note:   no known conversion for argument 1 from const char* to std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&) {aka std::basic_ios<char>& (*)(std::basic_ios<char>&)}
/usr/include/c++/4.8.2/istream:131:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(ios_base& (*__pf)(ios_base&))
       ^
/usr/include/c++/4.8.2/istream:131:7: note:   no known conversion for argument 1 from const char* to std::ios_base& (*)(std::ios_base&)
/usr/include/c++/4.8.2/istream:168:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(bool& __n)
       ^
/usr/include/c++/4.8.2/istream:168:7: note:   no known conversion for argument 1 from const char* to bool&
/usr/include/c++/4.8.2/istream:172:7: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]
       operator>>(short& __n);
       ^
/usr/include/c++/4.8.2/istream:172:7: note:   no known conversion for argument 1 from const char* to short int&
/usr/include/c++/4.8.2/istream:175:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(unsigned short& __n)
       ^
/usr/include/c++/4.8.2/istream:175:7: note:   no known conversion for argument 1 from const char* to short unsigned int&
/usr/include/c++/4.8.2/istream:179:7: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]
       operator>>(int& __n);
       ^
/usr/include/c++/4.8.2/istream:179:7: note:   no known conversion for argument 1 from const char* to int&
/usr/include/c++/4.8.2/istream:182:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(unsigned int& __n)
       ^
/usr/include/c++/4.8.2/istream:182:7: note:   no known conversion for argument 1 from const char* to unsigned int&
/usr/include/c++/4.8.2/istream:186:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(long& __n)
       ^
/usr/include/c++/4.8.2/istream:186:7: note:   no known conversion for argument 1 from const char* to long int&
/usr/include/c++/4.8.2/istream:190:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(unsigned long& __n)
       ^
/usr/include/c++/4.8.2/istream:190:7: note:   no known conversion for argument 1 from const char* to long unsigned int&
/usr/include/c++/4.8.2/istream:195:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(long long& __n)
       ^
/usr/include/c++/4.8.2/istream:195:7: note:   no known conversion for argument 1 from const char* to long long int&
/usr/include/c++/4.8.2/istream:199:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(unsigned long long& __n)
       ^
/usr/include/c++/4.8.2/istream:199:7: note:   no known conversion for argument 1 from const char* to long long unsigned int&
/usr/include/c++/4.8.2/istream:214:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(float& __f)
       ^
/usr/include/c++/4.8.2/istream:214:7: note:   no known conversion for argument 1 from const char* to float&
/usr/include/c++/4.8.2/istream:218:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(double& __f)
       ^
/usr/include/c++/4.8.2/istream:218:7: note:   no known conversion for argument 1 from const char* to double&
/usr/include/c++/4.8.2/istream:222:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(long double& __f)
       ^
/usr/include/c++/4.8.2/istream:222:7: note:   no known conversion for argument 1 from const char* to long double&
/usr/include/c++/4.8.2/istream:235:7: note: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]
       operator>>(void*& __p)
       ^
/usr/include/c++/4.8.2/istream:235:7: note:   no known conversion for argument 1 from const char* to void*&
/usr/include/c++/4.8.2/istream:259:7: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__streambuf_type*) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf<char>]
       operator>>(__streambuf_type* __sb);
       ^
/usr/include/c++/4.8.2/istream:259:7: note:   no known conversion for argument 1 from const char* to std::basic_istream<char>::__streambuf_type* {aka std::basic_streambuf<char>*}
In file included from /usr/include/c++/4.8.2/string:53:0,
                 from /usr/include/c++/4.8.2/bits/locale_classes.h:40,
                 from /usr/include/c++/4.8.2/bits/ios_base.h:41,
                 from /usr/include/c++/4.8.2/ios:42,
                 from /usr/include/c++/4.8.2/ostream:38,
                 from /usr/include/c++/4.8.2/iostream:39,
                 from assignment26.cpp:15:
/usr/include/c++/4.8.2/bits/basic_string.tcc:996:5: note: template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::basic_string<_CharT, _Traits, _Alloc>&)
     operator>>(basic_istream<_CharT, _Traits>& __in,
     ^
/usr/include/c++/4.8.2/bits/basic_string.tcc:996:5: note:   template argument deduction/substitution failed:
assignment26.cpp:22:11: note:   mismatched types std::basic_string<_CharT, _Traits, _Alloc> and const char*
    cin >> fileName;
           ^
In file included from /usr/include/c++/4.8.2/istream:882:0,
                 from /usr/include/c++/4.8.2/iostream:40,
                 from assignment26.cpp:15:
/usr/include/c++/4.8.2/bits/istream.tcc:955:5: note: template<class _CharT2, class _Traits2> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, _CharT2*)
     operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s)
     ^
/usr/include/c++/4.8.2/bits/istream.tcc:955:5: note:   template argument deduction/substitution failed:
assignment26.cpp:22:11: note:   deduced conflicting types for parameter _CharT2 (char and const char)
    cin >> fileName;
           ^
In file included from /usr/include/c++/4.8.2/istream:882:0,
                 from /usr/include/c++/4.8.2/iostream:40,
                 from assignment26.cpp:15:
/usr/include/c++/4.8.2/bits/istream.tcc:923:5: note: template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, _CharT&)
     operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c)
     ^
/usr/include/c++/4.8.2/bits/istream.tcc:923:5: note:   template argument deduction/substitution failed:
assignment26.cpp:22:11: note:   deduced conflicting types for parameter _CharT (char and const char*)
    cin >> fileName;
           ^
In file included from /usr/include/c++/4.8.2/iostream:40:0,
                 from assignment26.cpp:15:
/usr/include/c++/4.8.2/istream:727:5: note: template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char&)
     operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
     ^
/usr/include/c++/4.8.2/istream:727:5: note:   template argument deduction/substitution failed:
assignment26.cpp:22:11: note:   cannot convert fileName (type const char*) to type unsigned char&
    cin >> fileName;
           ^
In file included from /usr/include/c++/4.8.2/iostream:40:0,
                 from assignment26.cpp:15:
/usr/include/c++/4.8.2/istream:732:5: note: template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char&)
     operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
     ^
/usr/include/c++/4.8.2/istream:732:5: note:   template argument deduction/substitution failed:
assignment26.cpp:22:11: note:   cannot convert fileName (type const char*) to type signed char&
    cin >> fileName;
           ^
In file included from /usr/include/c++/4.8.2/iostream:40:0,
                 from assignment26.cpp:15:
/usr/include/c++/4.8.2/istream:774:5: note: template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char*)
     operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s)
     ^
/usr/include/c++/4.8.2/istream:774:5: note:   template argument deduction/substitution failed:
assignment26.cpp:22:11: note:   cannot convert fileName (type const char*) to type unsigned char*
    cin >> fileName;
           ^
In file included from /usr/include/c++/4.8.2/iostream:40:0,
                 from assignment26.cpp:15:
/usr/include/c++/4.8.2/istream:779:5: note: template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char*)
     operator>>(basic_istream<char, _Traits>& __in, signed char* __s)
     ^
/usr/include/c++/4.8.2/istream:779:5: note:   template argument deduction/substitution failed:
assignment26.cpp:22:11: note:   cannot convert fileName (type const char*) to type signed char*
    cin >> fileName;
           ^
assignment26.cpp: In function float readFile(const char*):
assignment26.cpp:38:13: error: statement cannot resolve address of overloaded function
    fin.close;
             ^
assignment26.cpp: In function int main():
assignment26.cpp:60:46: error: expected primary-expression before ] token
    char fileName[256] = getFileName(fileName[]);
                                              ^
assignment26.cpp:61:38: error: expected primary-expression before ] token
    float average = readFile(fileName[]);
                                      ^
[living4god1991 at LinuxLab01 ~]$ g++ assignment26.cppsubmit assignment25.cppg++ assignment26.cppsubmit assignment25.cppg++ assignment26.cpp
assignment26.cpp: In function float readFile(const char*):
assignment26.cpp:38:13: error: statement cannot resolve address of overloaded function
    fin.close;
             ^
assignment26.cpp: In function int main():
assignment26.cpp:60:46: error: expected primary-expression before ] token
    char fileName[256] = getFileName(fileName[]);
                                              ^
assignment26.cpp:61:38: error: expected primary-expression before ] token
    float average = readFile(fileName[]);
                                      ^
[living4god1991 at LinuxLab01 ~]$ g++ assignment26.cpp
assignment26.cpp: In function float readFile(const char*):
assignment26.cpp:38:13: error: statement cannot resolve address of overloaded function
    fin.close;
             ^
assignment26.cpp: In function int main():
assignment26.cpp:60:45: error: array must be initialized with a brace-enclosed initializer
    char fileName[256] = getFileName(fileName);
                                             ^
[living4god1991 at LinuxLab01 ~]$ g++ assignment26.cpp
assignment26.cpp: In function int main():
assignment26.cpp:60:46: error: expected primary-expression before ] token
    char fileName[256] = getFileName(fileName[]);
                                              ^
assignment26.cpp:61:38: error: expected primary-expression before ] token
    float average = readFile(fileName[]);
                                      ^
[living4god1991 at LinuxLab01 ~]$ g++ assignment26.cpp
assignment26.cpp: In function int main():
assignment26.cpp:60:45: error: array must be initialized with a brace-enclosed initializer
    char fileName[256] = getFileName(fileName);
                                             ^
[living4god1991 at LinuxLab01 ~]$ g++ assignment26.cpp
[living4god1991 at LinuxLab01 ~]$ a.out
Please enter the filename: grades.txt
Error reading file "grades.txt"
Average Grade: 77.00%[living4god1991 at LinuxLab01 ~]$ a.out
Please enter the filename: ^[[A^[[A^[[B^[[B^A   grades.txt
Error reading file "rades.txt"
Error reading file "rades.txt"
Average Grade: 0.00%[living4god1991 at LinuxLab01 ~]$ g++ assignment26.cpp
[living4god1991 at LinuxLab01 ~]$ g++ assignment26.cppa.out
Please enter the filename: grades.txt
Error reading file "grades.txt"
Average Grade: 77.00%[living4god1991 at LinuxLab01 ~]$ a.outg++ assignment26.cpp
assignment26.cpp: In function void display(float):
assignment26.cpp:52:42: error: fileName was not declared in this scope
       cout << "Error reading file \"" << fileName << "\"\n";
                                          ^
[living4god1991 at LinuxLab01 ~]$ g++ assignment26.cppa.out
Please enter the filename: grades.txt
Error reading file "grades.txt"
Average Grade: 77.00%[living4god1991 at LinuxLab01 ~]$ a.out
Please enter the filename: ^[[A^[[B        grades.txt
Error reading file "grades.txt"
Average Grade: 77.00%[living4god1991 at LinuxLab01 ~]$ a.outg++ assignment26.cpp
[living4god1991 at LinuxLab01 ~]$ g++ assignment26.cppa.out
Please enter the filename: grades.txt
Error reading file "grades.txt"
Error reading file "grades.txt"
Average Grade: 0.00%[living4god1991 at LinuxLab01 ~]$ a.out
Please enter the filename: grades.txt
Error reading file "grades.txt"
Error reading file "grades.txt"
Average Grade: 0.00%[living4god1991 at LinuxLab01 ~]$ !tg
g++ assignment26.cpp
assignment26.cpp: In function float readFile(const char*):
assignment26.cpp:27:26: error: expected primary-expression before ] token
    ifstream fin(fileName[]);
                          ^
[living4god1991 at LinuxLab01 ~]$ g++ assignment26.cppa.out
Please enter the filename: grades.txt
Error reading file "grades.txt"
Error reading file "grades.txt"
Average Grade: 0.00%[living4god1991 at LinuxLab01 ~]$ a.outg++ assignment26.cpp
[living4god1991 at LinuxLab01 ~]$ a.out
Please enter the filename: grades.txt
Error reading file "grades.txt"
Average Grade: 77.00%[living4god1991 at LinuxLab01 ~]$ a.outg++ assignment26.cpp
[living4god1991 at LinuxLab01 ~]$ g++ assignment26.cppa.out
Please enter the filename: grades.tex  xt
Error reading file "grades.txt"
Average Grade: 77.00%[living4god1991 at LinuxLab01 ~]$ a.outg++ assignment26.cppa.outg++ assignment26.cpp
[living4god1991 at LinuxLab01 ~]$ g++ assignment26.cppa.out
Please enter the filename: grades.txt
Error reading file "grades.txt"
Average Grade: 77.00%[living4god1991 at LinuxLab01 ~]$ a.outg++ assignment26.cpp
[living4god1991 at LinuxLab01 ~]$ a.out
Please enter the filename: grades.txt
Average Grade: 77.00%[living4god1991 at LinuxLab01 ~]$ g++ -- version
g++: error: version: No such file or directory
g++: error: unrecognized command line option --
g++: fatal error: no input files
compilation terminated.
[living4god1991 at LinuxLab01 ~]$ g++ -version
g++: error: unrecognized command line option -version
g++: fatal error: no input files
compilation terminated.
[living4god1991 at LinuxLab01 ~]$ g++ --version
g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-16)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[living4god1991 at LinuxLab01 ~]$ g++ --versionversion- versiona.outg++ assignment26.cpp
[living4god1991 at LinuxLab01 ~]$ a.out
Please enter the filename: grades.txt
Average Grade: 77.00%[living4god1991 at LinuxLab01 ~]$ testBed cs124/assignme26 assignment26.cpp

a.out:

------------------------------------------------------------
Starting Test 1

Here we will read the file that has the following text:
   90 86 95 76 92 83 88 87 91 100
The sum is 888 so the average is 88.8%. You will need to round
correctly using the cout.precision() statement

   > Please enter the filename: /home/cs124/assignments/assign26a.txt
   > Average Grade: 88.00%
Exp: Average Grade: 89%\n

Test 1 failed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 2

this is the same as before except there is an extra newline at the
end of the file. Your program will need to not read the last number
twice. If you do, the sum will be 988 which will yield 89.8%.
Read the section in the book titled "Reading to the end of the file"
for a discussion on why this might happen and how to fix it

   > Please enter the filename: /home/cs124/assignments/assign26b.txt
   > Average Grade: 88.00%
Exp: Average Grade: 89%\n

Test 2 failed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 3

This should yield an error because there are 12 items in the file

   > Please enter the filename: /home/cs124/assignments/assign26c.txt
   > Error reading file "/home/cs124/assignments/assign26c.txt"
   > Average Grade: 0.00%
Exp: No output

Test 3 failed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 4

This should yield an error because there are 3 items in the file

   > Please enter the filename: /home/cs124/assignments/assign26d.txt
   > Error reading file "/home/cs124/assignments/assign26d.txt"
   > Average Grade: 0.00%
Exp: No output

Test 4 failed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 5

This should yield an error because the file does not exist

   > Please enter the filename: /home/cs124/assignments/assign26e.txt
   > Error reading file "/home/cs124/assignments/assign26e.txt"
   > Error reading file "/home/cs124/assignments/assign26e.txt"\n
Exp: No output

Test 5 failed.
------------------------------------------------------------


============================================================
Failed 5/5 tests.
============================================================

[living4god1991 at LinuxLab01 ~]$ testBed cs124/assign26 assignment26.cpp

a.out:

------------------------------------------------------------
Starting Test 1

Here we will read the file that has the following text:
   90 86 95 76 92 83 88 87 91 100
The sum is 888 so the average is 88.8%. You will need to round
correctly using the cout.precision() statement

   > Please enter the filename: /home/cs124/assignments/assign26a.txt
   > Average Grade: 88%  
Exp: Average Grade: 89%\n

Test 1 failed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 2

this is the same as before except there is an extra newline at the
end of the file. Your program will need to not read the last number
twice. If you do, the sum will be 988 which will yield 89.8%.
Read the section in the book titled "Reading to the end of the file"
for a discussion on why this might happen and how to fix it

   > Please enter the filename: /home/cs124/assignments/assign26b.txt
   > Average Grade: 88%  
Exp: Average Grade: 89%\n

Test 2 failed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 3

This should yield an error because there are 12 items in the file

   > Please enter the filename: /home/cs124/assignments/assign26c.txt
   > Error reading file "/home/cs124/assignments/assign26c.txt"
   > Average Grade: 0%
Exp: No output

Test 3 failed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 4

This should yield an error because there are 3 items in the file

   > Please enter the filename: /home/cs124/assignments/assign26d.txt
   > Error reading file "/home/cs124/assignments/assign26d.txt"
   > Average Grade: 0%
Exp: No output

Test 4 failed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 5

This should yield an error because the file does not exist

   > Please enter the filename: /home/cs124/assignments/assign26e.txt
   > Error reading file "/home/cs124/assignments/assign26e.txt"
   > Error reading file "/home/cs124/assignments/assign26e.txt"\n
Exp: No output

Test 5 failed.
------------------------------------------------------------


============================================================
Failed 5/5 tests.
============================================================

[living4god1991 at LinuxLab01 ~]$ testBed cs124/assign26 assignment26.cpp

a.out:

------------------------------------------------------------
Starting Test 1

Here we will read the file that has the following text:
   90 86 95 76 92 83 88 87 91 100
The sum is 888 so the average is 88.8%. You will need to round
correctly using the cout.precision() statement

   > Please enter the filename: /home/cs124/assignments/assign26a.txt
   > Average Grade: 89%

Test 1 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 2

this is the same as before except there is an extra newline at the
end of the file. Your program will need to not read the last number
twice. If you do, the sum will be 988 which will yield 89.8%.
Read the section in the book titled "Reading to the end of the file"
for a discussion on why this might happen and how to fix it

   > Please enter the filename: /home/cs124/assignments/assign26b.txt
   > Average Grade: 89%

Test 2 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 3

This should yield an error because there are 12 items in the file

   > Please enter the filename: /home/cs124/assignments/assign26c.txt
   > Error reading file "/home/cs124/assignments/assign26c.txt"
   > Average Grade: 0%\n
Exp: No output

Test 3 failed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 4

This should yield an error because there are 3 items in the file

   > Please enter the filename: /home/cs124/assignments/assign26d.txt
   > Error reading file "/home/cs124/assignments/assign26d.txt"
   > Average Grade: 0%\n
Exp: No output

Test 4 failed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 5

This should yield an error because the file does not exist

   > Please enter the filename: /home/cs124/assignments/assign26e.txt
   > Error reading file "/home/cs124/assignments/assign26e.txt"
   > Error reading file "/home/cs124/assignments/assign26e.txt"\n
Exp: No output

Test 5 failed.
------------------------------------------------------------


============================================================
Failed 3/5 tests.
============================================================

[living4god1991 at LinuxLab01 ~]$ testBed cs124/assign26 assignment26.cpp

a.out:

------------------------------------------------------------
Starting Test 1

Here we will read the file that has the following text:
   90 86 95 76 92 83 88 87 91 100
The sum is 888 so the average is 88.8%. You will need to round
correctly using the cout.precision() statement

   > Please enter the filename: /home/cs124/assignments/assign26a.txt
   > Average Grade: 89%

Test 1 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 2

this is the same as before except there is an extra newline at the
end of the file. Your program will need to not read the last number
twice. If you do, the sum will be 988 which will yield 89.8%.
Read the section in the book titled "Reading to the end of the file"
for a discussion on why this might happen and how to fix it

   > Please enter the filename: /home/cs124/assignments/assign26b.txt
   > Average Grade: 89%

Test 2 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 3

This should yield an error because there are 12 items in the file

   > Please enter the filename: /home/cs124/assignments/assign26c.txt
   > Error reading file "/home/cs124/assignments/assign26c.txt"

Test 3 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 4

This should yield an error because there are 3 items in the file

   > Please enter the filename: /home/cs124/assignments/assign26d.txt
   > Error reading file "/home/cs124/assignments/assign26d.txt"

Test 4 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 5

This should yield an error because the file does not exist

   > Please enter the filename: /home/cs124/assignments/assign26e.txt
   > Error reading file "/home/cs124/assignments/assign26e.txt"
   > Error reading file "/home/cs124/assignments/assign26e.txt"\n
Exp: No output

Test 5 failed.
------------------------------------------------------------


============================================================
Failed 1/5 tests.
============================================================

[living4god1991 at LinuxLab01 ~]$ testBed cs124/assign26 assignment26.cpp
/tmp/GgFR8NQrdK/assignment26.cpp: In function float readFile(char*):
/tmp/GgFR8NQrdK/assignment26.cpp:50:28: error: expected identifier before ( token
    if (numGrades != 10) && (!fin.fail))
                            ^
/tmp/GgFR8NQrdK/assignment26.cpp:50:28: error: expected ; before ( token

Error compiling /tmp/GgFR8NQrdK/assignment26.cpp.
[living4god1991 at LinuxLab01 ~]$ testBed cs124/assign26 assignment26.cpp
/tmp/QPa7hqXXta/assignment26.cpp:1:1: error: stray \3 in program
 /***********************************************************************
 ^
/tmp/QPa7hqXXta/assignment26.cpp:1:1: error: stray \3 in program
/tmp/QPa7hqXXta/assignment26.cpp: In function float readFile(char*):
/tmp/QPa7hqXXta/assignment26.cpp:50:28: error: expected identifier before ! token
    if (numGrades != 10) && !fin.fail())
                            ^
/tmp/QPa7hqXXta/assignment26.cpp:50:28: error: expected ; before ! token

Error compiling /tmp/QPa7hqXXta/assignment26.cpp.
[living4god1991 at LinuxLab01 ~]$ testBed cs124/assign26 assignment26.cpp
/tmp/UM9QgN6LSz/assignment26.cpp:1:1: error: stray \3 in program
 /***********************************************************************
 ^
/tmp/UM9QgN6LSz/assignment26.cpp:1:1: error: stray \3 in program
/tmp/UM9QgN6LSz/assignment26.cpp: In function float readFile(char*):
/tmp/UM9QgN6LSz/assignment26.cpp:50:28: error: expected identifier before ! token
    if (numGrades != 10) && !fin.fail())
                            ^
/tmp/UM9QgN6LSz/assignment26.cpp:50:28: error: expected ; before ! token

Error compiling /tmp/UM9QgN6LSz/assignment26.cpp.
[living4god1991 at LinuxLab01 ~]$ testBed cs124/assign26 assignment26.cpp
/tmp/xXklHmjgPR/assignment26.cpp: In function float readFile(char*):
/tmp/xXklHmjgPR/assignment26.cpp:50:28: error: expected identifier before ! token
    if (numGrades != 10) && !(fin.fail()))
                            ^
/tmp/xXklHmjgPR/assignment26.cpp:50:28: error: expected ; before ! token

Error compiling /tmp/xXklHmjgPR/assignment26.cpp.
[living4god1991 at LinuxLab01 ~]$ testBed cs124/assign26 assignment26.cpp
/tmp/iA6l_SM7GS/assignment26.cpp: In function float readFile(char*):
/tmp/iA6l_SM7GS/assignment26.cpp:50:28: error: expected identifier before ( token
    if (numGrades != 10) && (fin.fail != true)
                            ^
/tmp/iA6l_SM7GS/assignment26.cpp:50:28: error: expected ; before ( token

Error compiling /tmp/iA6l_SM7GS/assignment26.cpp.
[living4god1991 at LinuxLab01 ~]$ testBed cs124/assign26 assignment26.cpp
testBed cs124/assign26 assignment26.cpp
/tmp/XHN99hyTJN/assignment26.cpp: In function float readFile(char*):
/tmp/XHN99hyTJN/assignment26.cpp:50:28: error: expected identifier before ( token
    if (numGrades != 10) && (fin.fail == false)
                            ^
/tmp/XHN99hyTJN/assignment26.cpp:50:28: error: expected ; before ( token

Error compiling /tmp/XHN99hyTJN/assignment26.cpp.
[living4god1991 at LinuxLab01 ~]$ testBed cs124/assign26 assignment26.cpp
/tmp/eUFQP3JhSa/assignment26.cpp: In function float readFile(char*):
/tmp/eUFQP3JhSa/assignment26.cpp:49:42: error: invalid use of member function (did you forget the () ?)
    if ((numGrades != 10) && (fin.fail == false))
                                          ^
/tmp/eUFQP3JhSa/assignment26.cpp: At global scope:
/tmp/eUFQP3JhSa/assignment26.cpp:60:1: error: expected declaration before } token
 }
 ^

Error compiling /tmp/eUFQP3JhSa/assignment26.cpp.
[living4god1991 at LinuxLab01 ~]$ testBed cs124/assign26 assignment26.cpp
/tmp/ZD8kzkenot/assignment26.cpp:60:1: error: expected declaration before } token
 }
 ^

Error compiling /tmp/ZD8kzkenot/assignment26.cpp.
[living4god1991 at LinuxLab01 ~]$ testBed cs124/assign26 assignment26.cpp

a.out:

------------------------------------------------------------
Starting Test 1

Here we will read the file that has the following text:
   90 86 95 76 92 83 88 87 91 100
The sum is 888 so the average is 88.8%. You will need to round
correctly using the cout.precision() statement

   > Please enter the filename: /home/cs124/assignments/assign26a.txt
   > Average Grade: 89%

Test 1 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 2

this is the same as before except there is an extra newline at the
end of the file. Your program will need to not read the last number
twice. If you do, the sum will be 988 which will yield 89.8%.
Read the section in the book titled "Reading to the end of the file"
for a discussion on why this might happen and how to fix it

   > Please enter the filename: /home/cs124/assignments/assign26b.txt
   > Average Grade: 89%

Test 2 passed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 3

This should yield an error because there are 12 items in the file

   > Please enter the filename: /home/cs124/assignments/assign26c.txt
   > Average Grade: 171%\n                                       
Exp: Error reading file "/home/cs124/assignments/assign26c.txt"\n

Test 3 failed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 4

This should yield an error because there are 3 items in the file

   > Please enter the filename: /home/cs124/assignments/assign26d.txt
   > Average Grade: 2%\n                                         
Exp: Error reading file "/home/cs124/assignments/assign26d.txt"\n

Test 4 failed.
------------------------------------------------------------

------------------------------------------------------------
Starting Test 5

This should yield an error because the file does not exist

   > Please enter the filename: /home/cs124/assignments/assign26e.txt
   > Error reading file "/home/cs124/assignments/assign26e.txt"
   > Average Grade: -nan%\n
Exp: No output

Test 5 failed.
------------------------------------------------------------


============================================================
Failed 3/5 tests.
============================================================

[living4god1991 at LinuxLab01 ~]$ 


More information about the NFBCS mailing list