So I am having trouble with the most popular error ever, memory access violation. To make a long story short I am dabbling with an old program I once wrote, it's main purpose is to parse some stuff and download some files. (It's too huge all in all so I will only post relevant snippets)
The access violation is odd because it occurs after a while (to be exact, the 8th time the following snippet is called) which makes it even harder to figure out where the problem is. The error occurs at this line of code:
URLDownloadToFileA(0, Download, "somefile.txt", 0, 0);
Download is a char array initialized like this
char Download[200] = {0};
It is only touched in code at two locations, first one is when I fill it with data (I actually construct a url to pass to URLDownloadToFileA):
for(int i = 0; i < SomeValue; i++)
{
Download[i] = SomeContent[i]
}
Something like that. Naturally SomeValue will never be bigger than the array size.
Second time is when I clear it, I do this after downloading a file before I construct the next url to pass
for(int i = 0; i < 200; i++)
{
Download[i] = '\0';
}
That's it. I'm puzzled, maybe I made a huge mistake somehow but I don't see how this could lead to memory access violations. And if I had screwed up somehow I would assume I would get a error directly and not after running the program for a while.
Debugger doesn't give anymore info than that the URLDownloadToFileA is the faulty line. So I guess the error must occur when it tries to access Download. I tried everything but I'm stuck with stupid dev cpp and it doesn't seem to be any way to find out more.
I know this is a little vague and all but perhaps someone have an idea on why this keep happening?