C++ assinging string Warning C6385 Reading invalid data from ‘"<>"’: the readable size is ‘3’ bytes, but ’40’ bytes may be read

  assign, c++

I am a student working on a project where we have to create a program to calculate the GPA for several students. Everything was going smoothly until I wrote a function to output a heading to a file. Basically i want to make a line that goes across the screen, something I have done this way in the past with no problems.

void print_heading(ofstream& fout)
{
    string line;
    line = line.assign("<>", 40);
    string dashes;
    dashes = dashes.assign('-', 80);
    fout << line << "nn";
    fout << setw(40) << right << "PCCC GPA Reportnn";
    fout << line << "nn";
    fout << dashes;
}

I don’t get an error, but I do get a warning (im using MS Visual Studio 2019 if relevant):
Warning C6385 Reading invalid data from ‘"<>"’: the readable size is ‘3’ bytes, but ’40’ bytes may be read.

my output looks like this:

<>  PCCC GPA Report

   :AM:am:PM:pm

                   PCCC GPA Report

<>  PCCC GPA Report

   :AM:am:PM:pm

PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP

I have used a similar method in the past and have not had any problems. Thanks in advance for any help.

EDIT: the string of PPPPPPP… is a part of my output, I think it corresponts to the variable dashes.

Source: Windows Questions C++

LEAVE A COMMENT