Hello,
I want to read a file and to pass the values in a buffer but the values are of different datatype. So I cant put the values in the char type buffer.
What to do?
I found this but dint worked for me...
Anyone can help..!
Thanks :)
I want to read a file and to pass the values in a buffer but the values are of different datatype. So I cant put the values in the char type buffer.
What to do?
I found this but dint worked for me...
Code:
void print ( char *Buffer, usigned long bufferSize, int chunkSize );
/*This fn will accept file buffer and the buffer size and the chunk size
Send the buffer in chunks which is provided by the parameter.
*/
FILE *fp23 = fopen( "c:\\file.txt", "rb" );
fseek (fp23 , 0 , SEEK_END);
int m_jobSize = ftell (fp23);
rewind (fp23);
char* m_buffer = new char[m_jobSize+1];
int m_result = fread( m_buffer, 1, m_jobSize, fp23 );
int chunkSize = 1;
void print ( m_buffer, m_jobSize, chunkSize);
void print ( char *m_buffer, usigned long m_jobSize, int chunkSize)
{
int BytesIndex = 0;
while( bufsize > 0)
{
if ( bufsize < (unsigned long)iSendStatus ) // Send some bytes
{
iSendStatus = send(*sock, &m_buffer[BytesIndex], bufsize, 0);
// Call Back Function
set += iSendStatus;
ptr(jobid,set);
if ( iSendStatus != bufsize )
{
cpError = SocketErrorHandler();
return cpError;
}
}
else
{
iSendStatus = send(*sock, &m_buffer[BytesIndex], chunkSize, 0);
// Call Back Function
set += iSendStatus;
ptr(jobid,set);
if ( iSendStatus != chunkSize )
{
cpError = SocketErrorHandler();
return cpError;
}
}
// Update buffer and counter
if ( bufsize < (unsigned long)iSendStatus )
{
bufsize -= bufsize;
BytesIndex += bufsize;
}
else
{
bufsize -= iSendStatus;
BytesIndex +=iSendStatus;
}
}
Anyone can help..!
Thanks :)
Comment