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... -
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 :)
3 9372
fread() doesn't care what the buffer type is. That argument is a void*. Just define your buffer of the correct type and pass the address to fread().
Couldn't make out with the work, still.
Dint understood, how to do..!
This is fread() prototype: -
size_t fread(
-
void *buffer,
-
size_t size,
-
size_t count,
-
FILE *stream
-
);
-
To read 1000 ints you would: -
int buffer[1000]
-
fread(buffer, sizeof(int), 1000, myFile);
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: clwoods |
last post by:
I would like to ask is thier a better way to store data other than access
tables, I would still like to keep access as the front end. My main quest I
suppose is for more speed and maybe security....
|
by: Forconi Boris via .NET 247 |
last post by:
Hi, I'm working on a project in witch I have to list data(products that can be selected with a certain quantity) from anXML document, with key words entered by the user. A Table isdynamically created...
|
by: jmensch |
last post by:
Hello. I'm a reasonably new ASP.NET programmer
with no prior ASP or web development experience,
but a lot of general programming experience. I'm
using Visual Web Developer Beta Express 2005.
...
|
by: Crirus |
last post by:
Hi
I have about 1000 records of users to store.. I dont like the ideea of a
database server...
How to store does data in a structured way?
An XML?
How big can became such an xml, because I...
|
by: piotrek |
last post by:
Hi
I would like to ask you a question.
Ian creating app. that download from server directory structure ( whole
tree ) and those data are placed in proper places into my treeview control.
I...
|
by: res7cxbi |
last post by:
hi,
im familiar with xml but wondering if it would be better to store data
within attributes:
<root>
<data value="someData"/>
</root>
or within nodes:
|
by: TYF |
last post by:
hello, im completely new to c and programming.
now i need to store data from a input buffer in a struct and then sending the struct back, not the buffer, but i dont know how to start.any help...
|
by: nurulshidanoni |
last post by:
i hava a data
student id examcode
1 002
006
001
2 123
589
How to store data when it have...
|
by: asharda |
last post by:
Hello,
I have written a sample async code (using callback/async).
I am now seeing a situation where-in if two messages are received at
the same-time, both of them show-up in the data-buffer.
...
|
by: creative1 |
last post by:
Is this possible to store data in an XML file using HTML form? I got it working other way. I can store data in an xml file and display it in html form. I need to do it other way. It is very urgent. ...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |