how do i fix c26001

Daniel Shepherd 246 Reputation points
2021-04-09T22:51:28.08+00:00

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.

Developer technologies | C++
{count} votes

Accepted answer
  1. Daniel Shepherd 246 Reputation points
    2021-04-10T11:48:27.677+00:00

    never mind. it just randomly stopped getting the warning and started working.


3 additional answers

Sort by: Most helpful
  1. Daniel Shepherd 246 Reputation points
    2021-04-09T22:55:22.53+00:00

    this was actually c6001. my mistake.

    0 comments No comments

  2. David Lowndes 4,726 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!

    0 comments No comments

  3. 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?


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.