Click here to Skip to main content
15,041,025 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Inconsistentcies Between Win32 and MFC Pin
ForNow11-Aug-16 10:30
MemberForNow11-Aug-16 10:30 
GeneralRe: Inconsistentcies Between Win32 and MFC Pin
jeron111-Aug-16 10:46
Memberjeron111-Aug-16 10:46 
GeneralRe: Inconsistentcies Between Win32 and MFC Pin
ForNow11-Aug-16 11:31
MemberForNow11-Aug-16 11:31 
GeneralRe: Inconsistentcies Between Win32 and MFC Pin
jeron111-Aug-16 12:24
Memberjeron111-Aug-16 12:24 
GeneralRe: Inconsistentcies Between Win32 and MFC Pin
ForNow11-Aug-16 15:49
MemberForNow11-Aug-16 15:49 
GeneralRe: Inconsistentcies Between Win32 and MFC Pin
leon de boer12-Aug-16 4:38
Memberleon de boer12-Aug-16 4:38 
GeneralRe: Inconsistentcies Between Win32 and MFC Pin
ForNow12-Aug-16 5:01
MemberForNow12-Aug-16 5:01 
QuestionC fread to read 512k binary file Pin
Fossi Bluman10-Aug-16 11:57
MemberFossi Bluman10-Aug-16 11:57 
I use the bellow code to read binary file but it throws an exceptions at run time and sometimes gives a wrong results , please tell me what's the wrong ?

#include <stdio.h>
#include <stdlib.h>

unsigned long size,n;
int main()
{
unsigned char *buf;
FILE* fp;
	fp=fopen ("myfile.bin","rb");
	if (fp == NULL) {
  	fprintf(stderr, "Can't open the file");
  	exit(1);}

	fseek (fp,0,SEEK_END);	//
	size=ftell (fp);		//	get the size of the file
	fseek (fp,0,SEEK_SET);	//

	if ((buf=(unsigned char*) malloc (size+1))==0)
		printf("\n%s","allocation Error");

	n=fread (buf,sizeof (buf),size,fp);
	printf ("\n%02x %lu bytes read",buf[15],n);

	free (buf);
	fclose (fp);
	return 0;
}


modified 11-Aug-16 16:40pm.

QuestionRe: C fread to read 512k binary file Pin
David Crow10-Aug-16 16:45
MemberDavid Crow10-Aug-16 16:45 
AnswerRe: C fread to read 512k binary file Pin
k505411-Aug-16 12:46
mvek505411-Aug-16 12:46 
GeneralRe: C fread to read 512k binary file Pin
David Crow11-Aug-16 16:24
MemberDavid Crow11-Aug-16 16:24 
AnswerRe: C fread to read 512k binary file Pin
Daniel Pfeffer10-Aug-16 21:15
professionalDaniel Pfeffer10-Aug-16 21:15 
GeneralRe: C fread to read 512k binary file Pin
Fossi Bluman11-Aug-16 1:58
MemberFossi Bluman11-Aug-16 1:58 
GeneralRe: C fread to read 512k binary file Pin
Daniel Pfeffer11-Aug-16 3:54
professionalDaniel Pfeffer11-Aug-16 3:54 
GeneralRe: C fread to read 512k binary file Pin
Fossi Bluman11-Aug-16 6:56
MemberFossi Bluman11-Aug-16 6:56 
AnswerRe: C fread to read 512k binary file Pin
Software_Developer20-Aug-16 0:03
MemberSoftware_Developer20-Aug-16 0:03 
GeneralRe: C fread to read 512k binary file Pin
Fossi Bluman23-Aug-16 6:45
MemberFossi Bluman23-Aug-16 6:45 
QuestionVector as function return Pin
Donguy19769-Aug-16 15:40
MemberDonguy19769-Aug-16 15:40 
AnswerRe: Vector as function return Pin
Richard MacCutchan9-Aug-16 20:57
mveRichard MacCutchan9-Aug-16 20:57 
QuestionAdding Text to the Frame Of a Dialog Pin
ForNow9-Aug-16 4:39
MemberForNow9-Aug-16 4:39 
AnswerRe: Adding Text to the Frame Of a Dialog Pin
jeron19-Aug-16 8:33
Memberjeron19-Aug-16 8:33 
GeneralRe: Adding Text to the Frame Of a Dialog Pin
ForNow9-Aug-16 13:07
MemberForNow9-Aug-16 13:07 
AnswerRe: Adding Text to the Frame Of a Dialog Pin
leon de boer9-Aug-16 19:05
Memberleon de boer9-Aug-16 19:05 
GeneralRe: Adding Text to the Frame Of a Dialog Pin
ForNow10-Aug-16 3:47
MemberForNow10-Aug-16 3:47 
SuggestionRe: Adding Text to the Frame Of a Dialog Pin
David Crow10-Aug-16 5:41
MemberDavid Crow10-Aug-16 5:41 

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.