Menu

Something wrong with string class

2005-10-05
2012-09-26
  • Nobody/Anonymous

    1)Dev 4.9.9.2 on windows xp sp2

    2)
    //Curved Grading

    include "iostream.h"

    include "fstream.h"

    include "math.h"

    include "iomanip.h"

    include <string.h>

    include "stdlib.h"

    int main()
    {
    char ch;
    int n=10;
    int set[n], i, j,sum=0;
    float m, sd, devsum;

    cout << "Enter the name of teh input file";
    string inputFileName;
    getline(cin, inputFileName);

    for(i=0; i<n; i++)
    {
    cout << "Input number: ";
    cin >> set[i];
    }

    for(i=0; i<n;i++)
    sum = set[i] + sum;

    m = sum/n;

    for(i=0;i<n;i++)
    devsum = ((set[i] - m) * (set[i] - m) + devsum);

    sd = sqrt(devsum/n);

    for(i=0;i<n;i++)
    {
    if (set[i] < (m - 1.5*sd))
    cout << "F \n";

    else if(set[i] < (m - .5 * sd))
    cout << "D \n";

    else if(set[i] < (m + .5 * sd))
    cout << "C \n";

    else if(set[i] < (m + 1.5 * sd))
    cout << "B \n";

    else
    cout << "A \n";

    }

    cin >> ch;
    return 0;
    }

    3)Compiler: Default compiler
    Executing g++.exe...
    g++.exe "F:\Dev-Cpp\Programs\Curved Grading.cpp" -o "F:\Dev-Cpp\Programs\Curved Grading.exe" -traditional-cpp -g3 -I"F:\Dev-Cpp\lib\gcc\mingw32\3.4.2\include" -I"F:\Dev-Cpp\include\c++\3.4.2\backward" -I"F:\Dev-Cpp\include\c++\3.4.2\mingw32" -I"F:\Dev-Cpp\include\c++\3.4.2" -I"F:\Dev-Cpp\include" -L"F:\Dev-Cpp\lib" -g3
    In file included from F:/Dev-Cpp/include/c++/3.4.2/backward/iostream.h:31,
    from F:\Dev-Cpp\Programs\Curved Grading.cpp:3:
    F:/Dev-Cpp/include/c++/3.4.2/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated.
    F:\Dev-Cpp\Programs\Curved Grading.cpp: In function int main()': F:\Dev-Cpp\Programs\Curved Grading.cpp:22: error:string' undeclared (first use this function)
    F:\Dev-Cpp\Programs\Curved Grading.cpp:22: error: (Each undeclared identifier is reported only once for each function it appears in.)
    F:\Dev-Cpp\Programs\Curved Grading.cpp:22: error: expected ;' before &quot;inputFileName&quot; F:\Dev-Cpp\Programs\Curved Grading.cpp:23: error:inputFileName' undeclared (first use this function)

    Execution terminated

     
    • Nobody/Anonymous

      include <string>

      using namespace std;

       
    • Nobody/Anonymous

      And convert the old header files to their new names (see compiler warning) and replace their speech marks (") with angle bracket <>

       
    • Anonymous

      Anonymous - 2005-10-05

      Not only is the use of the .h extension deprecated for C++, <string.h> is not and never was the header for the C++ string class. It is the header for the C string library.

      Did you actually read the error messages (that is after all what they are for!). The one that says "#warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <X> header for the <X.h> header for C++ includes, or <iostream> instead of the deprecated header <iostream.h>. To disable this warning use -Wno-deprecated. " is pretty explicit.

      Clifford

       

Log in to post a comment.

MongoDB Logo MongoDB