473,667 Members | 2,568 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8097
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.********@com Acast.net> wrote in message news:<ZX******* ***********@new sread1.dllstx09 .us.to.verio.ne t>...
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**********@ya hoo.com (Rajesh N Thipse) wrote in message news:<79******* *************** ****@posting.go ogle.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**********@y ahoo.com> wrote:
Victor Bazarov <v.********@com Acast.net> wrote in message
news:<ZX****** ************@ne wsread1.dllstx0 9.us.to.verio.n et>...
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*******@pres by.edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA
Jul 22 '05 #5
ra**********@ya hoo.com (Rajesh N Thipse) wrote in message news:<79******* *************** ****@posting.go ogle.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::filesyst em
http://www.boost.org/libs/filesystem/doc/index.htm

Regards,
Michiel Salters
Jul 22 '05 #6
ra**********@ya hoo.com (Rajesh N Thipse) wrote in message news:<79******* *************** ****@posting.go ogle.com>...
ra**********@ya hoo.com (Rajesh N Thipse) wrote in message news:<79******* *************** ****@posting.go ogle.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
6773
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 achieve this is to write the report to a temporary file, or more likely to a temporary directory with a separate file for each page. I can use that for previewing and for printing, and then delete the file/directory. There seems to be a few ways to...
5
3332
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
3169
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 wrapper avec le control center (j'ai utilisé DRDA) et ensuite j'ai voulu créé le serveur mais avec le wizard, il ne me présente pas mes tables ! J'ai donc essayé en ligne de commande. J'ai essayé la commande suivante: CREATE SERVER TEST TYPE...
7
8852
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 want my users to be able to select a report, click on a command button on a form, which will then automatically create the report as a pdf file and save it to the user's machine. I am using Adobe Acrobat (5.0 I think) and have Adobe Distiller as a
2
2193
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 does not work, although I can through code open and copy files from "\Docs"
8
20354
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: Start with original thumbnails & two empty sub directories STEP 2: Create smaller versions of the originals for one sub directory STEP 3: Create thumbnail version of the originals the other sub directory STEP 4: Create an index.html pointing to the...
23
7397
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 in an array. The application compiles but aborts without giving me any useful information. What I suspect is happening is infinite recursion. Each Directory object creates an array of Subdirectories each of which has an array of...
0
956
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 the current directory by using Server.MapPath(null); and then manually create a directory and map to it like so string path = Server.MapPath(null); UploadPath = path + "\\bin\\Upload";
16
3876
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 aspx page with the CreateUserWizard control. The user can fill his username, password etc .... My problem is: when an user fills everything and clicks on button "create an account", nothing happens (no error, but no user account created). I...
4
6902
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 function creates the file as expected. When I loop through my array I get the error - "ArgumentException was unhandled - Illegal characters in path" The value "C:\Temp.txt" is the first value in the array - as it works
0
8457
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8646
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7390
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6203
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4200
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2776
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1778
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.