Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File is not creating if not exist. #1

Open
prakhargvp opened this issue May 7, 2017 · 3 comments
Open

File is not creating if not exist. #1

prakhargvp opened this issue May 7, 2017 · 3 comments

Comments

@prakhargvp
Copy link
Owner

fstream file;
file.open(fname.c_str(),fstream::out | fstream::in);
@prakhargvp
Copy link
Owner Author

prakhargvp commented May 7, 2017

fstream::in does not create file. So file open the file in out mode then in input and out mode.

fstream file;
file.open(fname.c_str(),fstream::out, fstream::app);

@rishabhgupta1322
Copy link
Collaborator

what does c_str function do and how does it work?

@prakhargvp
Copy link
Owner Author

prakhargvp commented May 11, 2017

@rishabhgupta1322 c_str is a method in string object. It convert string type object into c string (character array).
Since so many function accept character string as argument not string type object.
SO that's why we are using stringObject.c_str() method to get character array.

Repository owner deleted a comment from feras-ragheb Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants