Click here to Skip to main content
15,917,005 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: the difference of using custom control and picture ? Pin
cyn819-Nov-06 14:44
cyn819-Nov-06 14:44 
GeneralRe: the difference of using custom control and picture ? Pin
Mark Salsbery20-Nov-06 5:03
Mark Salsbery20-Nov-06 5:03 
QuestionHashing algorithms Pin
Waldermort18-Nov-06 20:51
Waldermort18-Nov-06 20:51 
AnswerRe: Hashing algorithms Pin
PJ Arends18-Nov-06 23:44
professionalPJ Arends18-Nov-06 23:44 
AnswerRe: Hashing algorithms Pin
El Corazon19-Nov-06 5:12
El Corazon19-Nov-06 5:12 
AnswerRe: Hashing algorithms Pin
Jörgen Sigvardsson19-Nov-06 5:36
Jörgen Sigvardsson19-Nov-06 5:36 
AnswerRe: Hashing algorithms Pin
Blake Miller22-Nov-06 3:58
Blake Miller22-Nov-06 3:58 
Questionfgetc/fputc crashes with long filenames [modified] Pin
chichina18-Nov-06 17:33
chichina18-Nov-06 17:33 
Hi! This is my first post on the web ever! Smile | :)

To make it short, I made a routine to change certain bytes in a file in binary mode. It all worked perfectly, until I decided to use a long name directory and it crashes. I made certain check points to find out exactly where it crashes and why. Here is my subroutine code:

void binary_edit (char *cur_dir) {
	FILE *fp,*fp2;
	char filename[100],filename2[100];
	int temp,cur_bit=0;
	sprintf(filename ,"%s\\file1.bin",cur_dir);
	sprintf(filename2,"%s\\file2.bin",cur_dir);
	fp=fopen(filename,"rb");
	fp2=fopen(filename2,"wb");

	temp=(int)fgetc(fp); //chrashes if filename=>41 chars :confused:
	while (!feof(fp)) {
		switch (cur_bit) {
			case 50:fputc(0,fp2);break;
			case 51:fputc(1,fp2);break;
			case 52:fputc(2,fp2);break;
			case 53:fputc(3,fp2);break;
			case 54:fputc(4,fp2);break;
			case 55:fputc(5,fp2);break;
			default:fputc(temp,fp2);
		}
 		cur_bit+=1;
		temp=(int)fgetc(fp);
	}

 	//crashes if filename2=>39 chars :confused:
	fclose(fp);
	fclose(fp2);
	unlink(filename);
	rename(filename2,filename);
}


Please help me out

Chichi



-- modified at 0:21 Sunday 19th November, 2006
AnswerRe: fgetc/fputc crashes with long filenames Pin
PJ Arends18-Nov-06 18:45
professionalPJ Arends18-Nov-06 18:45 
GeneralRe: fgetc/fputc crashes with long filenames Pin
chichina18-Nov-06 18:59
chichina18-Nov-06 18:59 
AnswerRe: fgetc/fputc crashes with long filenames [modified] Pin
Steve Echols18-Nov-06 18:59
Steve Echols18-Nov-06 18:59 
GeneralRe: fgetc/fputc crashes with long filenames Pin
chichina18-Nov-06 19:04
chichina18-Nov-06 19:04 
GeneralRe: fgetc/fputc crashes with long filenames Pin
Steve Echols18-Nov-06 19:16
Steve Echols18-Nov-06 19:16 
GeneralRe: fgetc/fputc crashes with long filenames Pin
chichina18-Nov-06 19:22
chichina18-Nov-06 19:22 
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 
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 

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.