Click here to Skip to main content
15,881,882 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Objects in Array loops, need help Pin
Cedric Moonen17-Sep-09 4:19
Cedric Moonen17-Sep-09 4:19 
AnswerRe: Objects in Array loops, need help Pin
CPallini17-Sep-09 4:44
mveCPallini17-Sep-09 4:44 
Questionlibrary files not getting created in debug mode(VC++) Pin
Vetukuri Raju17-Sep-09 3:25
Vetukuri Raju17-Sep-09 3:25 
GeneralRe: library files not getting created in debug mode(VC++) Pin
David Crow17-Sep-09 3:45
David Crow17-Sep-09 3:45 
GeneralRe: library files not getting created in debug mode(VC++) Pin
Vetukuri Raju17-Sep-09 4:31
Vetukuri Raju17-Sep-09 4:31 
GeneralRe: library files not getting created in debug mode(VC++) Pin
David Crow17-Sep-09 4:34
David Crow17-Sep-09 4:34 
GeneralRe: library files not getting created in debug mode(VC++) Pin
Vetukuri Raju17-Sep-09 4:38
Vetukuri Raju17-Sep-09 4:38 
QuestionFile access in C++ Pin
Durga_Devi17-Sep-09 3:19
Durga_Devi17-Sep-09 3:19 
Hi,

While reading the double value from the written text file, the memory get corrupetd.Here is the sample code and its output for the scenario. Can anyone help in this.

#include <stdio.h>;
#include "stdafx.h"

int main(int argc, char* argv[])
{
double dbleArray[][4] = { -315.00000255999998,0.00000000000000000,0.00000000000000000,-166.19238000000001,
			  -329.19238000000001,315.00000255999998,-329.19238000000001,-329.19238000000001,
			  0.00000000000000000,0.00000000000000000,320.00000000000000,-536.00000000000000,
			  0.00000000000000000,0.00000000000000000,0.00000000000000000,1.0000000000000000};

	//Write the data to the file
	FILE* pFile = NULL;
	pFile = _wfopen(L"C:\\Temp\\InputVolumeDetails.txt", L"w");
	if(pFile)
	{
		for(int nRow=0; nRow<4; nRow++)
		{
			for(int nCol=0; nCol<4; nCol++)
			{
				fwrite(&dbleArray[nRow][nCol], sizeof(double), 1, pFile);
			}
		}
	}
	fclose(pFile);

	//Read the data from the file
	double dbleArray_r[4][4];
	FILE* pFile_r = NULL;
	pFile_r = _wfopen(L"C:\\Temp\\InputVolumeDetails.txt", L"r");
	if(pFile_r)
	{
		for(int nRow=0; nRow<4; nRow++)
		{
			for(int nCol=0; nCol<4; nCol++)
			{
				fread(&dbleArray_r[nRow][nCol], sizeof(double), 1, pFile_r);
				printf("%f\n",dbleArray_r[nRow][nCol]);
			}
		}
	}
	fclose(pFile);

	return 0;
}

The output for the above code is

-315.000003
0.000000
0.000000
-92559631348757048000000000000000000000000000000000000000000000.000000
-92559631349317831000000000000000000000000000000000000000000000.000000
-92559631349317831000000000000000000000000000000000000000000000.000000
-92559631349317831000000000000000000000000000000000000000000000.000000
-92559631349317831000000000000000000000000000000000000000000000.000000
-92559631349317831000000000000000000000000000000000000000000000.000000
-92559631349317831000000000000000000000000000000000000000000000.000000
-92559631349317831000000000000000000000000000000000000000000000.000000
-92559631349317831000000000000000000000000000000000000000000000.000000
-92559631349317831000000000000000000000000000000000000000000000.000000
-92559631349317831000000000000000000000000000000000000000000000.000000
-92559631349317831000000000000000000000000000000000000000000000.000000
-92559631349317831000000000000000000000000000000000000000000000.000000

AnswerRe: File access in C++ Pin
Romualdas Cukuras17-Sep-09 3:24
Romualdas Cukuras17-Sep-09 3:24 
AnswerRe: File access in C++ Pin
Richard MacCutchan17-Sep-09 9:42
mveRichard MacCutchan17-Sep-09 9:42 
GeneralRe: File access in C++ Pin
Durga_Devi17-Sep-09 18:21
Durga_Devi17-Sep-09 18:21 
GeneralRe: File access in C++ Pin
Richard MacCutchan17-Sep-09 22:31
mveRichard MacCutchan17-Sep-09 22:31 
QuestionHow to get the default value of the registry? Pin
deadlyabbas17-Sep-09 1:10
deadlyabbas17-Sep-09 1:10 
AnswerRe: How to get the default value of the registry? Pin
David Crow17-Sep-09 2:07
David Crow17-Sep-09 2:07 
QuestionCannot see windows XP styles on MFC controls Pin
itsmerajesh17-Sep-09 0:57
itsmerajesh17-Sep-09 0:57 
AnswerRe: Cannot see windows XP styles on MFC controls Pin
Naveen17-Sep-09 1:08
Naveen17-Sep-09 1:08 
GeneralRe: Cannot see windows XP styles on MFC controls Pin
krmed17-Sep-09 7:09
krmed17-Sep-09 7:09 
GeneralRe: Cannot see windows XP styles on MFC controls Pin
Naveen17-Sep-09 17:42
Naveen17-Sep-09 17:42 
Questionexecuting .bat file in Vista64 bit Pin
Madan Chauhan17-Sep-09 0:43
Madan Chauhan17-Sep-09 0:43 
AnswerRe: executing .bat file in Vista64 bit Pin
«_Superman_»17-Sep-09 1:01
professional«_Superman_»17-Sep-09 1:01 
GeneralRe: executing .bat file in Vista64 bit Pin
Madan Chauhan17-Sep-09 1:26
Madan Chauhan17-Sep-09 1:26 
QuestionRe: executing .bat file in Vista64 bit Pin
Randor 17-Sep-09 1:03
professional Randor 17-Sep-09 1:03 
QuestionRe: executing .bat file in Vista64 bit Pin
David Crow17-Sep-09 2:13
David Crow17-Sep-09 2:13 
QuestionHow to get the path of Acrobat Reader Exe by C++ Pin
deadlyabbas17-Sep-09 0:15
deadlyabbas17-Sep-09 0:15 
AnswerRe: How to get the path of Acrobat Reader Exe by C++ Pin
«_Superman_»17-Sep-09 0:31
professional«_Superman_»17-Sep-09 0:31 

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.