Member Avatar for tawes01

I'm using Dev-c++ to make a dialog-based app. I had it working, but now I am getting an error:
An Access Violation (Segmentation Fault) raised in your program.

I have narrowed it down to the winmain function:

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow) {
   if (iCmdShow > 4) {
      commandlineopener=szCmdLine;
   }
   gCmdShow=iCmdShow;
   strcat(about,version);
   strcat(about,"Stuff"); //About stuffs go here
   DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), 0,(DLGPROC)MainDlgProc);
   WSACleanup();
   return 0;
}

What am I doing wrong?

Recommended Answers

All 4 Replies

You strcat version and "Stuff" into about...What's 'about'? Can we see its definition?

Member Avatar for tawes01

I have it defined as global, right after the includes:

char about[128]="C++ dialog-based plain text editor, version ";

But I had that before, and it was working, so I don't think that's the problem...

Member Avatar for tawes01

I tried adding a MessageBox after each action in the function. The program actually crashes after WSACleanup. But that can't be right, can it? I've never heard of a problem with the return...

Member Avatar for tawes01

OK. I figured it out. Apparently, the whole strcat() stuff was doing something that it didn't like, and I moved all the data to the declaration of about. After I deleted the strcat()'s, it no longer crashed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.