wasim6691 Posted December 26, 2017 Report Share Posted December 26, 2017 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. Quote Link to comment Share on other sites More sharing options...
maehne Posted December 26, 2017 Report Share Posted December 26, 2017 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 AmeyaVS and David Black 2 Quote Link to comment Share on other sites More sharing options...
David Black Posted December 26, 2017 Report Share Posted December 26, 2017 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.