Qyaffer
Qyaffer

Reputation: 220

C code won't run on windows (Visual Studio 2013)

My program works fine on Linux running on GCC, however when I compile and run the code on Windows using Visual Studio 2013 it gives me this error : Unhandled exception at 0x00EC2527 in a3a3.exe: 0xC00000FD: Stack overflow (parameters: 0x00000000, 0x00692000).

It also inserts a breakpoint into crtexe.c at line 626; here are lines 624 - 626 for reference:

#else  /* WPRFLAG */
            __initenv = envp;
            mainret = main(argc, argv, envp);

I have compiled and ran C programs before using Visual Studio 2013, but this one doesn't seem to want to work and I cannot for the life of me determine why. I would greatly appreciate your help, I'm fairly new to programming and this is my first post on stackoverflow. I would as well appreciate any extra tips or criticism to help me learn. Thank you.

Here is my program : http://pastebin.com/X731mU7W

Upvotes: 2

Views: 2130

Answers (1)

Anthony
Anthony

Reputation: 12397

struct CR CRArray[14500] is too big to live on the stack (hence the Stack Overflow). Dynamically allocate it instead.

struct CR *CRArray = malloc (sizeof (struct CR) * 14500);

Although, because it's VS, you probably need to cast the return of malloc in this instance.

Also, don't forget to free the memory.

Upvotes: 5

Related Questions