By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,750 Members | 1,187 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,750 IT Pros & Developers. It's quick & easy.

How to store a File content in a variable using C

P: 8
Hi

I have generated one file ( this file contains only random numbers in binary form)
now i have to pass the content of file into some function,
so i want to store my content of file into a variable. file size may vary,
how to do this, pls help me.

Thanks
Feb 19 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 1,510
Hi

I have generated one file ( this file contains only random numbers in binary form)
now i have to pass the content of file into some function,
so i want to store my content of file into a variable. file size may vary,
how to do this, pls help me.

Thanks
in C++ you could read the values into a vector and pass that to the function, e.g.
http://www.cppreference.com/cppvector/index.html

in C you could use an array - you would need to determine the amount of data then malloc() storage for it
http://www.codeproject.com/tips/newandmalloc.asp
Feb 19 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.