473,394 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to create a Directory in C++?

Hi,
Files can be created using _creat.
Similarly, is there a function to create a directory?

~Rajesh
Jul 22 '05 #1
6 8076
Rajesh N Thipse wrote:
Files can be created using _creat.
Really? I don't know such function in the Standard library.
Similarly, is there a function to create a directory?


Similarly, no. Check the programming manual for your OS.

V
Jul 22 '05 #2
Victor Bazarov <v.********@comAcast.net> wrote in message news:<ZX******************@newsread1.dllstx09.us.t o.verio.net>...
Rajesh N Thipse wrote:
Files can be created using _creat.
Really? I don't know such function in the Standard library.

--------------------
In VC++, the following piece of code generates "temp" file
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>

void main( void )
{
int fh = _creat( "temp", _S_IREAD | _S_IWRITE );
if( fh == -1 )
perror( "Couldn't create data file" );
else
{
printf( "Created data file.\n" );
_close( fh );
}
}

Output

Created data file.
--------------------
Similarly, is there a function to create a directory?

Similarly, no. Check the programming manual for your OS.

--------------------
However, whether one uses _creat for creating a file or some other
function to do so is immaterial. The real question of creating a
directory remains unanswered.
I've checked programming manual, but didn't get much of help. Also
if I go for a OS specific function there can be an issue of
portability later.
--------------------
V

[A-Za-z ]+
Jul 22 '05 #3
ra**********@yahoo.com (Rajesh N Thipse) wrote in message news:<79**************************@posting.google. com>...
Hi,
Files can be created using _creat.
Similarly, is there a function to create a directory?

~Rajesh

I am able to do what I wanted. Thanks for all the replies and suggestions.
~Rajesh
Jul 22 '05 #4
In article <79**************************@posting.google.com >,
Rajesh N Thipse <ra**********@yahoo.com> wrote:
Victor Bazarov <v.********@comAcast.net> wrote in message
news:<ZX******************@newsread1.dllstx09.us. to.verio.net>...
Rajesh N Thipse wrote:
> Files can be created using _creat.


Really? I don't know such function in the Standard library.

--------------------
In VC++, the following piece of code generates "temp" file

[...]

But that is not standard C++. It uses Windows-specific functions. Here's
what I got when I tried to compile it under Mac OS X:

[Jon-Bells-Computer:~/Documents/c++] jtbell% c++ create.cpp
create.cpp:1:16: io.h: No such file or directory
create.cpp:8: error: `main' must return `int'
create.cpp: In function `int main(...)':
create.cpp:9: error: `_S_IREAD' undeclared (first use this function)
create.cpp:9: error: (Each undeclared identifier is reported only once for
each
function it appears in.)
create.cpp:9: error: `_S_IWRITE' undeclared (first use this function)
create.cpp:9: error: `_creat' undeclared (first use this function)
create.cpp:15: error: `_close' undeclared (first use this function)

--
Jon Bell <jt*******@presby.edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA
Jul 22 '05 #5
ra**********@yahoo.com (Rajesh N Thipse) wrote in message news:<79**************************@posting.google. com>...
Hi,
Files can be created using _creat. No, not in C++.
Similarly, is there a function to create a directory?


Not in standard C++, but it is possible with boost::filesystem
http://www.boost.org/libs/filesystem/doc/index.htm

Regards,
Michiel Salters
Jul 22 '05 #6
ra**********@yahoo.com (Rajesh N Thipse) wrote in message news:<79**************************@posting.google. com>...
ra**********@yahoo.com (Rajesh N Thipse) wrote in message news:<79**************************@posting.google. com>...
Hi,
Files can be created using _creat.
Similarly, is there a function to create a directory?

~Rajesh

I am able to do what I wanted. Thanks for all the replies and suggestions.
~Rajesh


This is the kind of people that we all wish to have as posters
to this newsgroup!

Stephan :-O
Jul 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Frank Millman | last post by:
Hi all I need to generate potentially large reports from a database, and I want to offer the option of print preview before actually printing (using wxPython). I figure that the best way to...
5
by: Ken Fine | last post by:
I want my application to maintain a directory tree based on months and years, e.g.: 2004 January file file file February file
9
by: jab | last post by:
Je veux lier (join) une table qui se trouve dans une database avec une qui se trouve dans une autre database. Les 2 databases sont sur le même serveur en l'occurence DB2/NT 7.2.9. J'ai créé un...
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
2
by: Paul Bromley | last post by:
How can I create a directory within a shared ntwork directory?? sServerName - is the Server name "\Docs" - is the shared directory "\Others" - is the directory to create. The following...
8
by: barb | last post by:
So that the world at large benefits from our efforts, here is one fully documented way to use Windows Irfanview freeware to create thumbnail web galleries (http://www.irfanview.com). STEP 1:...
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
0
by: roger_27 | last post by:
hey, I need to know how to create a directory in my web service application path. I have files uploading to a directory I want it to create called "Uploaded_files"... now I know that I can get...
16
by: Mich | last post by:
Hi, i'm building an web application for anonymous users. They can take a look in the website, nothing more. In order to perform other actions, the anonymous user must be logged. So i create an...
4
by: Vlad | last post by:
I am having problems using the file.create method within a function that is called when looping through an array of filepaths. If I call my function with a hardcoded file path --C:\Temp.txt the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.