In order to create a formatted file, I want to utilize fprintf. It must get char* parameters, but I have several string variables. How can I use fprintf?
In order to create a formatted file, I want to utilize fprintf . It
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The basic usage of
fprintfwith strings looks like this:You can add several strings by using several
%sformat specifiers and you can use repeated calls tofprintfto write the file incrementally.If you have C++
std::stringobjects you can use theirc_str()method to get aconst char*suitable to use withfprintf: