So i was making a program and i compiled and ran it, then for some weird reason it
doesnt work when i compile it now. I put some break points in (i put on into the
message loop too, it is pretty cool). I put them where I was editing the code most, part
of the file backup program, if you could help me find the bugs in it that would be cool


Code:
#include <windows.h>
#include <stdio.h>
#define ID_EDIT 1
#define ID_BUTTON 2
#define ID_STATIC 3

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
  FILE *pfile;
  FILE *pfile2;
  static HWND hwndEdit;
  static HWND hwndEdit2;
  static HWND hwndEdit3;
  static HWND hwndEdit4;
  static HWND hwndButton;
  static HWND hwndStatic;
  static HWND hwndStatic2;
  static HWND hwndStatic3;
  static HWND hwndStatic4;
  static HWND hwndStatic5;
  static int len;
  static CHAR text[1000];
  static CHAR text2[1000];
  static CHAR text3[1000];
  static CHAR text4[1000];
  
  switch(msg)
  {
    case WM_CREATE:
	hwndEdit = CreateWindow(TEXT("Edit"), NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_MULTILINE,
				50, 70, 170, 140, hwnd, (HMENU) ID_EDIT,
				NULL, NULL);

	hwndEdit2 = CreateWindow(TEXT("Edit"), NULL, WS_CHILD | WS_VISIBLE | WS_BORDER,
				50, 30, 20, 20, hwnd, (HMENU) ID_EDIT,
				NULL, NULL);
				
	hwndEdit3 = CreateWindow(TEXT("Edit"), NULL, WS_CHILD | WS_VISIBLE | WS_BORDER,
				120, 30, 20, 20, hwnd, (HMENU) ID_EDIT,
				NULL, NULL);
                
    hwndEdit4 = CreateWindow(TEXT("Edit"), NULL, WS_CHILD | WS_VISIBLE | WS_BORDER,
				190, 30, 40, 20, hwnd, (HMENU) ID_EDIT,
				NULL, NULL);  
                
    hwndStatic = CreateWindow(TEXT("static"), "please insert your date:", WS_CHILD | WS_VISIBLE,
				1, 1, 300, 20, hwnd, (HMENU) ID_STATIC,
				NULL, NULL);  
    
    hwndStatic2 = CreateWindow(TEXT("static"), "/", WS_CHILD | WS_VISIBLE,
				1, 5, 300, 20, hwnd, (HMENU) ID_STATIC,
				NULL, NULL); 
                                                  			
    hwndStatic3 = CreateWindow(TEXT("static"), "please insert your date:", WS_CHILD | WS_VISIBLE,
				1, 3, 300, 20, hwnd, (HMENU) ID_STATIC,
				NULL, NULL); 
				
	hwndStatic4 = CreateWindow(TEXT("static"), "please insert your date:", WS_CHILD | WS_VISIBLE,
				1, 4, 300, 20, hwnd, (HMENU) ID_STATIC,
				NULL, NULL); 			
				
				
	hwndStatic5 = CreateWindow(TEXT("static"), "please insert your date:", WS_CHILD | WS_VISIBLE,
				1, 5, 300, 20, hwnd, (HMENU) ID_STATIC,
				NULL, NULL); 			
				
    hwndButton = CreateWindow(
		TEXT("button"), TEXT("set title and write to file"),       
		WS_VISIBLE | WS_CHILD,  
		30, 240, 200, 25,        
		hwnd, (HMENU) ID_BUTTON, NULL, NULL);      

	break;

	case WM_COMMAND:	     
           if (HIWORD(wParam) == BN_CLICKED) {
               pfile = fopen("database1234.xls", "r");
               printf("break1");
               if(pfile == NULL){
               printf("breakloop2");
               MessageBox(hwnd,"the database for the program was deleted or moved, we will now use the backup,\neverything you enter now will be put into the original file\n and the backup\n the program will try to copy the backup.\n(the program will take care of everything)","database not found",MB_OK);
               printf("breakloop3");
               pfile2 = fopen("C:\\reminder\\data\\backup1.xls", "r");
               printf("breakloop4");
               if(pfile2 == NULL){
               printf("breakloop5");
               system("mkdir C:\\reminder\\data");
               printf("breakloop6");
               pfile = fopen("C:reminder\\data\\backup1.xls", "a");}
                        printf("breakloop");
                        }
               else{
               printf("breakloop7");
               fclose(pfile);
               printf("breakloop8");
               pfile = fopen("database1234.xls", "a");
                    printf("breakloop9");
                    }
               fclose(pfile);
              printf("break10");
              fclose(pfile2);
              printf("break11");
              pfile = fopen("database1234.xls", "a");
              printf("break12");
              pfile2 = fopen("C:\\reminder\\data\\backup1.xls", "a"); 
               printf("break13");
               len = GetWindowTextLength(hwndEdit) + 1;
               GetWindowText(hwndEdit, text, len);
               GetWindowText(hwndEdit2, text2, len);
               GetWindowText(hwndEdit3, text3, len);
               GetWindowText(hwndEdit4, text4, len);
               SetWindowText(hwnd, text);
               printf("break14");
               fprintf(pfile,"%s,%s,%s,\"%s\"\n",text2,text3,text4,text); 
               printf("break15");
               fprintf(pfile2,"%s,%s,%s,\"%s\"\n",text2,text3,text4,text);
               printf("break16");
               //MessageBox(hwnd,text,"text",MB_OK);
              printf("break17");
              fclose(pfile);
              printf("break18");
              fclose(pfile2);
           printf("break19");
           }
	break;

	case WM_DESTROY:
		PostQuitMessage(0);
	break;
  }
  return DefWindowProc(hwnd, msg, wParam, lParam);
}

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
			LPSTR lpCmdLine, int nCmdShow )
{
  MSG  msg ;    
  WNDCLASS wc = {0};
  wc.lpszClassName = TEXT( "Edit Control" );
  wc.hInstance     = hInstance ;
  wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
  wc.lpfnWndProc   = WndProc ;
  wc.hCursor       = LoadCursor(0,IDC_ARROW);

  
  RegisterClass(&wc);
  CreateWindow( wc.lpszClassName, TEXT("Edit control"),
                WS_OVERLAPPEDWINDOW | WS_VISIBLE,
                1000, 420, 280, 350, 0, 0, hInstance, 0);  

  while( GetMessage(&msg, NULL, 0, 0)) {
    printf("message");
    TranslateMessage(&msg);
    DispatchMessage(&msg);
  }
  return (int) msg.wParam;
}
thanks (and if you could take the cmd window out somehow too that would be cool)