Code:
	int _stdcall writeppm(BSTR filename, BSTR filepath, int framerate){		
		int iCount;
		long lItemNum;
		BYTE *pnOutBuf=new BYTE;
		WORD OutPicWidth, OutPicHeight;
		FILE *pfFile=new FILE;

		int start;
		char *name=new char[255];
		char *name1=new char[255];

		for(int i=0;i<=1800;i++){
			start = i * 60 + framerate;

			//set the filename
			if(start<10){
				strcpy(name,"f000000");
			} else if(start<1000){
				strcpy(name,"f00000");
			} else if(start<10000){
				strcpy(name,"f0000");
			} else if(start<100000){
				strcpy(name,"f000");
			} else if(start<1000000){
				strcpy(name,"f00");
			} else {
				strcpy(name,"f0");
			}

			//set the name
			char *buffer=new char[11];
				strcpy(name1,(LPCSTR)filepath);
				strcat(name1,(LPCSTR)filename);
				strcat(name1,name);
				strcat(name1,itoa(start,buffer,10));
				strcat(name1,".ppm");
		
			for (iCount=0;iCount<=1800;iCount++) {
				if (deco.GetCurFrameNum(&lResult)!=MDC_SUCCESS)
					return -2; //failed

				if (deco.DecodePicture()<0)
					return -3; //failed

				
				lItemNum=deco.GetCurFrame(pnOutBuf,&OutPicWidth,&OutPicHeight,PPM);
				if (lItemNum>0) {		
					MessageBox(NULL,"fopen","openfile",MB_OK); //debug
					if((pfFile = fopen(name1,"w+")) == NULL)
						return -4; //open file failed

it crashes on the fopen statement, first it says it cant write to the memory, then read. im calling the dll from VB, the calling etc works fine, and other functions work fine. it just crashes the vb ide and the program, with the error. ive narrowed it down to that line

ive tried different things for the file, like

FILE *pfFile = new FILE;
FILE *pfFile = NULL;
FILE *pfFile;

etc, any ideas?

oh yeah, i also did a MessageBox output for name1, that is fine.