TN888
TN888

Reputation: 7739

"Access denied" on launching application - Windows Vista

I've got administrator privileges at Windows Vista (SP1). I write a program in C++ in Dev-C++. That is my code :

#include <iostream>

using namespace std;

int main()
{
    int n[30000], i;
    i = 0;
    while(n[i] != 0)
    {
        cin >> n[i];
        i++;
    }
    //TODO 
}

I can compile that correctly, but when I try to launch that program in cmd I see follwing error :

Access denied

I tired to launch debbuing mode in my IDE, but then I saw following error :

Error on launching application(5) :

Access denied

I checked - my file isn't used by any other thread. Can you tell me what should I do to make that working propely ?

Upvotes: 0

Views: 142

Answers (1)

Some programmer dude
Some programmer dude

Reputation: 409136

Unrelated to your problem, but you have undefined behavior in your code. When you declare a local variable, even an array, its value is indeterminate. Using it before its initialized is undefined.

This means that your array n will basically contain random data, and you don't know when (if ever) there will be a zero. So you probably loop way beyond the boundaries of the array with your index, and write to those places.

Upvotes: 1

Related Questions