Click here to Skip to main content
15,890,717 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: RegOpenKeyEx gets error 5 (ERROR_ACCESS_DENIED) Pin
ShilpiP16-Feb-11 19:20
ShilpiP16-Feb-11 19:20 
GeneralRe: RegOpenKeyEx gets error 5 (ERROR_ACCESS_DENIED) Pin
Maxwell Chen16-Feb-11 20:03
Maxwell Chen16-Feb-11 20:03 
GeneralRe: RegOpenKeyEx gets error 5 (ERROR_ACCESS_DENIED) Pin
Richard Andrew x6417-Feb-11 11:55
professionalRichard Andrew x6417-Feb-11 11:55 
GeneralRe: RegOpenKeyEx gets error 5 (ERROR_ACCESS_DENIED) Pin
Maxwell Chen17-Feb-11 15:33
Maxwell Chen17-Feb-11 15:33 
GeneralRe: RegOpenKeyEx gets error 5 (ERROR_ACCESS_DENIED) Pin
ShilpiP17-Feb-11 17:39
ShilpiP17-Feb-11 17:39 
Questionstructure to file [REMAIN UNSOLVED] [CLOSED] Pin
goldenrose916-Feb-11 6:00
goldenrose916-Feb-11 6:00 
AnswerRe: structure to file Pin
Richard MacCutchan16-Feb-11 6:16
mveRichard MacCutchan16-Feb-11 6:16 
GeneralRe: structure to file Pin
goldenrose916-Feb-11 7:08
goldenrose916-Feb-11 7:08 
#include	<windows.h>
#include	<conio.h>
#include	<iostream>

using namespace std;

struct Detail{
	wchar_t Name[25];
	long	Age;
	wchar_t Address[100];
};

struct Student{
	Detail detail;
	DWORD code;
};
 
int main()
{

	DWORD BytesWritten=0, BytesRead=0;
	Student st,read;

	st.code =1;
	st.detail.Name = TEXT("Williams");
	st.detail.Age = 25;
	st.detail.Address = TEXT("B-33 Lane 5");
	
	
	HANDLE hFile = CreateFile(TEXT("C:\\demo.txt"),GENERIC_READ | GENERIC_WRITE,0,0,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,0);
	if (hFile != INVALID_HANDLE_VALUE)
	{
		WriteFile(hFile,&st,sizeof(Student),&BytesWritten,0);
		ReadFile(hFile,&read,sizeof(Student),&BytesRead,0);
		CloseHandle(hFile);

		cout<<read.code<<endl;
		cout<<read.detail.Name; 
	}
	else
	{
		cout<<"Error! Cannot Open File";
		exit(1);
	}
	_getche();
	return (0);
}



when executing this code following error occurs.

Error	1	error C2440: '=' : cannot convert from 'const wchar_t [9]' to 'wchar_t [25]'
Error	2	error C2440: '=' : cannot convert from 'const wchar_t [12]' to 'wchar_t [100]'	

Some Day I Will Prove MySelf :: GOLD

AnswerRe: structure to file Pin
David Crow16-Feb-11 7:56
David Crow16-Feb-11 7:56 
GeneralRe: structure to file [modified] Pin
goldenrose916-Feb-11 15:36
goldenrose916-Feb-11 15:36 
GeneralRe: structure to file Pin
David Crow16-Feb-11 16:33
David Crow16-Feb-11 16:33 
GeneralRe: structure to file Pin
ShilpiP16-Feb-11 19:33
ShilpiP16-Feb-11 19:33 
GeneralRe: structure to file Pin
Niklas L16-Feb-11 21:59
Niklas L16-Feb-11 21:59 
GeneralRe: structure to file Pin
David Crow17-Feb-11 1:51
David Crow17-Feb-11 1:51 
GeneralRe: structure to file Pin
goldenrose917-Feb-11 3:01
goldenrose917-Feb-11 3:01 
QuestionRe: structure to file Pin
David Crow17-Feb-11 4:14
David Crow17-Feb-11 4:14 
AnswerRe: structure to file Pin
goldenrose917-Feb-11 4:46
goldenrose917-Feb-11 4:46 
GeneralRe: structure to file Pin
David Crow17-Feb-11 4:57
David Crow17-Feb-11 4:57 
GeneralRe: structure to file Pin
goldenrose917-Feb-11 5:08
goldenrose917-Feb-11 5:08 
GeneralRe: structure to file Pin
David Crow17-Feb-11 5:11
David Crow17-Feb-11 5:11 
GeneralRe: structure to file Pin
goldenrose917-Feb-11 5:30
goldenrose917-Feb-11 5:30 
GeneralRe: structure to file Pin
David Crow17-Feb-11 7:13
David Crow17-Feb-11 7:13 
GeneralRe: structure to file Pin
goldenrose917-Feb-11 7:17
goldenrose917-Feb-11 7:17 
AnswerRe: structure to file Pin
Alain Rist16-Feb-11 11:41
Alain Rist16-Feb-11 11:41 
GeneralRe: structure to file Pin
Richard MacCutchan16-Feb-11 21:28
mveRichard MacCutchan16-Feb-11 21:28 

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.