never mind. it just randomly stopped getting the warning and started working.
how do i fix c26001
Daniel Shepherd
246
Reputation points
So, i am creating a console app DOS in visual studio 2019 until this in my code shows up:
#include <string>
#include <iostream>
int main()
{
const int* firstrun = new int[1];
std::string cmds = "cmds";
if (firstrun[1] == '1') {
std::cout << "loading MYDOS...\n";
std::cout << "MYDOS has been loaded. type commands or help to start. \n";
delete[] firstrun;
}
std::cin >> cmds;
if (cmds == "about") {
std::cout << "MYDOS version TEST-1.0 \n";
}
if (cmds == "help") {
std::cout << "please refer to instructions on mydos.htm. \n";
}
}
Warning C6001 Using uninitialized memory '*firstrun'. mydos_test1
How do i fix this! i have also referred to the help article. it did not help much.
Accepted answer
3 additional answers
Sort by: Most helpful
-
Daniel Shepherd 246 Reputation points
2021-04-09T22:55:22.53+00:00 this was actually c6001. my mistake.
-
David Lowndes 4,711 Reputation points
2021-04-09T23:04:21.96+00:00 const int* firstrun = new int[1];
if (firstrun[1] == '1')You've only allocated 1 item, so firstrun[1] is immediately off the end!
-
Daniel Shepherd 246 Reputation points
2021-04-09T23:06:09.577+00:00 im very new to c++ lol. does this mean i have to change that to a bigger number?