Reading a file.



Hi,
I am trying to read data from a file to a buffer.Then, i want to store
bitwise information of a particular byte to a different array.
Problem in doing so is, in memory, ASCII value of a character is getting
stored and right shifting that value would't give the correct bitwise
information.
Pl. help.

Code written for that is.

#include "stdafx.h"

bool hw[4][8][8];

int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
unsigned char inBuffer[256];
unsigned char i,j,k;
DWORD noofbytes = 0x00000001,nBytesRead;
HANDLE hservice = CreateFile(L"\\hi.txt",GENERIC_READ,0,NULL,
OPEN_EXISTING,0,NULL);
DWORD d = GetLastError();
if(hservice != INVALID_HANDLE_VALUE)
{
DWORD dwPtr = SetFilePointer(hservice,0x00,NULL,FILE_CURRENT);
if(dwPtr == 0xFFFFFFFF)
{
printf("Pointer set error = %ul\n",GetLastError());
// return 0;
}
else
{
BOOL bResult = ReadFile(hservice,&(inBuffer[i]),noofbytes,&nBytesRead,NULL);
DWORD d = GetLastError();
if(bResult && (nBytesRead == 0x01))
printf("Read Value = %x\n",inBuffer[i]);
else
printf("Error in Reading = %ul\n",d);
}
}
else
printf("Error in opening the file = %ul",d);
for(k=0;k<8;k++)
{
// printf("value of in Buffer = %d\n",inBuffer[j]);
if(inBuffer[0]>>k & 0x01)
hw[0][0][k] = TRUE;
else
hw[0][0][k] = FALSE;
printf("Value of hw[0][0][%d] = %d\n",k,hw[0][0][k]);
}
return 0;
}

.



Relevant Pages

  • Re: Reading a file.
    ... What happens if you take a array and fill it with hard coded data, ... int WINAPI WinMain(HINSTANCE hInstance, ... unsigned char inBuffer; ... DWORD d = GetLastError; ...
    (microsoft.public.windowsce.app.development)
  • Re: Reading a file.
    ... Bruce.Eitman AT EuroTech DOT com ... bitwise information of a particular byte to a different array. ... int WINAPI WinMain(HINSTANCE hInstance, ... DWORD d = GetLastError; ...
    (microsoft.public.windowsce.app.development)
  • Re: Need help to marshall Win32 DLL call to VB.net
    ... I allocate an array and I call GetDirInfo to fill the array ... DWORD WIMAAPI GetNbEntryCurDir; ... // LPDIRINFO: array of DIRINFO that will receive the info ... on C++ unmanager, I do: ...
    (microsoft.public.dotnet.languages.vb)
  • Need help to marshall Win32 DLL call to VB.net
    ... I allocate an array and I call GetDirInfo to fill the array ... DWORD WIMAAPI GetNbEntryCurDir; ... // LPDIRINFO: array of DIRINFO that will receive the info ... on C++ unmanager, I do: ...
    (microsoft.public.dotnet.languages.vb)
  • Re: IOCTL_POWER_XXX method calls
    ... Paul, I understand how to implement your suggestions if the parameter ... // in the managed array of bytes. ... internal const int DeviceDxOffset = 0; ... BOOL PWM_IOControl (DWORD hOpenContext, DWORD pwCode, PBYTE pBufIn, ...
    (microsoft.public.dotnet.framework.compactframework)

Loading