You are here:

C++/file permissions and C++

Advertisement


Question
#include <stdio.h>
#include <iostream.h>

int main(){
fopen("haha.txt","w");
cout << "Content-type: text/html\n\n";
cout << "<html><body>successful";
cout << "</body></html>";
return 0;
}


when i execute the following code online,
the new file that is produced haha.txt's file permission is set as nobody.

is there a way that i can set that permission to the owner of the execution file?

thank you..

Answer
Hello James, thank you for the question.

I actually had no idea how to do this, since I've never had to before, so I asked a coworker. He said that the C runtime functions stat() and fstat() should have you good to go. You can look these functions up in the MSDN library for detailed descriptions and code samples at msdn.microsoft.com. Sorry I couldn't provide a better explanation.

- Eddie

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Eddie

Expertise

I can answer questions about the C++ language, object oriented design and architecture. I am knowledgable in a lot of the math that goes into programming, and am certified by ExpertRating.com. I also know a good deal about graphics via OpenGL, and GUIs.

Experience

I have completed numerous games and demos created with the C++ programming language. Currently employed as a software engineer in the modeling and simulation field. I have about 7 years experience.

©2016 About.com. All rights reserved.