Click here to Skip to main content
15,909,656 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: fgetc/fputc crashes with long filenames Pin
Steve Echols18-Nov-06 20:04
Steve Echols18-Nov-06 20:04 
GeneralRe: fgetc/fputc crashes with long filenames Pin
Michael Dunn18-Nov-06 20:33
sitebuilderMichael Dunn18-Nov-06 20:33 
GeneralRe: fgetc/fputc crashes with long filenames Pin
Steve Echols18-Nov-06 20:36
Steve Echols18-Nov-06 20:36 
GeneralRe: fgetc/fputc crashes with long filenames Pin
chichina18-Nov-06 21:21
chichina18-Nov-06 21:21 
AnswerRe: fgetc/fputc crashes with long filenames Pin
Michael Dunn18-Nov-06 19:17
sitebuilderMichael Dunn18-Nov-06 19:17 
GeneralRe: fgetc/fputc crashes with long filenames Pin
chichina18-Nov-06 19:39
chichina18-Nov-06 19:39 
GeneralRe: fgetc/fputc crashes with long filenames Pin
Steve Echols18-Nov-06 20:02
Steve Echols18-Nov-06 20:02 
GeneralRe: fgetc/fputc crashes with long filenames Pin
chichina18-Nov-06 20:24
chichina18-Nov-06 20:24 
Thank you and everybody for the help. I just made a new script excluding all the rest of the stuff to figure out wth is going on. Here the complete script:
#include "stdafx.h"
#include <stdio.h>

void binedit (char *cur_dir) {
	FILE *fp,*fp2;
	char filename[256],filename2[256];
	int temp,cur_bit=0;
	sprintf(filename,"%s\\file1.bin",cur_dir);
	sprintf(filename2,"%s\\file2.bin",cur_dir);
	fp=fopen(filename,"rb");
	if (!fp) {MessageBox(NULL,"error filename","a",MB_OK);return;}
	fp2=fopen(filename2,"wb");
	if (!fp2) {MessageBox(NULL,"error filename2","a",MB_OK);return;}
	temp=(int)fgetc(fp);
	char a[256];
	sprintf(a,"%s %d",filename2,strlen(filename2));
	MessageBox(NULL,a,"param",MB_OK);
	while (!feof(fp)) {
		switch (cur_bit) {
			case 650:fputc(1,fp2);break;
			case 651:fputc(2,fp2);break;
			case 652:fputc(3,fp2);break;
			case 653:fputc(4,fp2);break;
			case 654:fputc(5,fp2);break;
			case 655:fputc(6,fp2);break;
			case 656:fputc(7,fp2);break;
			case 657:fputc(8,fp2);break;
			case 658:fputc(9,fp2);break;
			case 659:fputc(10,fp2);break;
			case 660:fputc(11,fp2);break;
			case 661:fputc(12,fp2);break;
			case 662:fputc(13,fp2);break;
			default:fputc(temp,fp2);
		}
		cur_bit+=1;
		temp=(int)fgetc(fp);
	}
	fclose(fp);
	fclose(fp2);
	unlink(filename);
	rename(filename2,filename);
}


int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
                     LPSTR lpCmdLine,int nCmdShow) {
	char *cur_dir;
	cur_dir=new char;
	GetCurrentDirectory(512,cur_dir);
	binedit(cur_dir);
	return 0;                                          
}


I run this exe from the explorer in "C:\p1231231\asdasdasd" without any problems. if i add a 2 to the first directory "C:\p12312312\asdasdasd" I still have no problems. However if I changed it to "C:\p12312312123123123123\asdasdasd" I get a crash. I do not understand.
Does the other ppl who r trying to help me also receive this POST? or do I have to reply him as well with the code also. Sorry but I'm noob in this.

Chichilina
GeneralRe: fgetc/fputc crashes with long filenames Pin
Michael Dunn18-Nov-06 20:31
sitebuilderMichael Dunn18-Nov-06 20:31 
GeneralRe: fgetc/fputc crashes with long filenames Pin
chichina18-Nov-06 20:40
chichina18-Nov-06 20:40 
GeneralRe: fgetc/fputc crashes with long filenames Pin
Steve Echols18-Nov-06 20:34
Steve Echols18-Nov-06 20:34 
AnswerRe: fgetc/fputc crashes with long filenames Pin
Scott Holt20-Nov-06 15:50
Scott Holt20-Nov-06 15:50 
GeneralRe: fgetc/fputc crashes with long filenames Pin
chichina20-Nov-06 16:00
chichina20-Nov-06 16:00 
QuestionHow source codeCRC10 ??? Pin
patter77718-Nov-06 16:49
patter77718-Nov-06 16:49 
QuestionConsole window output [modified] Pin
locoone18-Nov-06 16:01
locoone18-Nov-06 16:01 
AnswerRe: Console window output Pin
Michael Dunn18-Nov-06 16:50
sitebuilderMichael Dunn18-Nov-06 16:50 
AnswerRe: Console window output Pin
tiaozi19-Nov-06 20:52
tiaozi19-Nov-06 20:52 
QuestionLine spacing in an edit box Pin
Sorin Basca18-Nov-06 10:39
Sorin Basca18-Nov-06 10:39 
AnswerRe: Line spacing in an edit box Pin
Mark Salsbery18-Nov-06 13:17
Mark Salsbery18-Nov-06 13:17 
GeneralRe: Line spacing in an edit box Pin
Sorin Basca19-Nov-06 6:03
Sorin Basca19-Nov-06 6:03 
GeneralRe: Line spacing in an edit box Pin
Mark Salsbery19-Nov-06 6:07
Mark Salsbery19-Nov-06 6:07 
Questionclass function pointer to LPVOID Pin
edvintas18-Nov-06 10:16
edvintas18-Nov-06 10:16 
AnswerRe: class function pointer to LPVOID Pin
Waldermort18-Nov-06 10:30
Waldermort18-Nov-06 10:30 
GeneralRe: class function pointer to LPVOID Pin
edvintas18-Nov-06 10:58
edvintas18-Nov-06 10:58 
QuestionNotifications and messages in win app. Pin
sawerr18-Nov-06 9:24
sawerr18-Nov-06 9:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.