Jump to content
wasim6691

Reading a binary File

Recommended Posts

Hello 

I wand to read the binary file in System C. Can I use the malloc() function as we used in C to store the content of the file in some buffer. Thanks. The fread() command is used in System C or there is some other command in System C.

Share this post


Link to post
Share on other sites

Yes, you can use C's fread() function for this purpose. However, you should not use malloc()/free() to handle allocation/deallocation of your buffers. Instead, use C++'s new/delete operators or even better a suitable standard container such as std::array<T, N> or std::vector<T>. C++'s <iostream> library also offers you the possibility to read/write binary data from/to files.

SystemC is a C++ library. Therefore, I suggest that you get familiar with C++ first. Confer, e.g., to:

https://isocpp.org/get-started

http://www.cplusplus.com/reference/iolibrary/

https://stackoverflow.com/questions/8798127/binary-input-output-in-c

Share this post


Link to post
Share on other sites

I concur with Maehne's recommendations. Good SystemC requires mastering C++. If you can take a good class, it will accelerate your learning even more. Also, good C++ means throwing out much of your C habits and taking proper advantage of the easier (and safer) to code C++ STL containers and methods.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...