Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing in an element from an Array of Pointers

Status
Not open for further replies.

azntekkan

Programmer
Jun 5, 2003
10
CA
Hi, I'm trying to use an array to hold some information from a file. Here is my code.


byte * buffer[30];

for(int j=0;j<30;i++)
{
buffer[j]=(byte *)malloc(518400);
}

//then i open a file-this part has no problems

ReadFile(videoYUV,buffer[1],518400,&bytesread,&gOverLapped);


The read in part fails. But when I use a regular pointer (i.e byte * buffer=(byte *) malloc(518400) )it works. I was wandering if i'm passing in the pointer wrong or something. Please help me out. Thanks in advance.
 
Don't really understand what you're doing.
Anyway, maybe this helps

BYTE* FileToBuffer(char* szFileName, DWORD* lpdwSize)
{
HANDLE hFile;
DWORD dwSize, dw_nobr;
BYTE* bytes;

//Obtain a handle to the file
hFile = CreateFile(
szFileName,
GENERIC_READ,
0,
NULL,OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);

//Get size of the file
dwSize = GetFileSize(hFile, NULL);

//Allocate space for file data
bytes = (BYTE *)malloc(dwSize);

//Read file data into buffer
ReadFile(hFile, bytes, dwSize, &dw_nobr, NULL);

//Done with the handle
CloseHandle(hFile);

//Set the size
lpdwSize = dwSize;

//ofcourse...
return bytes;
}

I left out error handling for clarity.
 
do not know, but try

ReadFile(videoYUV,*buffer[1],518400,&bytesread,&gOverLapped);
or
ReadFile(videoYUV,*(buffer[1]),518400,&bytesread,&gOverLapped);
or
ReadFile(videoYUV,(*buffer)[1],518400,&bytesread,&gOverLapped);
[hippy]


Greetings Andreas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top