Solved

write  to a process

Posted on 2004-04-08
9
166 Views
Last Modified: 2010-04-22
sir ,

mkdir rath
 will create a directory  .
with out using system() ,i hve to  
make a directory called xxx

 ie
     int  main(int argc ,char *argv[])
     {
     }
i  hve to pass directory name as an argument.
0
Comment
Question by:karana
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 12

Expert Comment

by:stefan73
ID: 10783345
Hi karana,
Like this:

int main(int argc,char** argv){
    if(argc!=2){
        [error... not exactly one argument]
    }

    mkdir(argv[0]);
}

Cheers,
Stefan
0
 
LVL 12

Accepted Solution

by:
stefan73 earned 50 total points
ID: 10783350
> mkdir(argv[0]);
...should read
mkdir(argv[1]);

argv[0] is the program name itself, not the first argument.

Stefan
0
 

Author Comment

by:karana
ID: 10791529
sir ,

 i  hve to use popen()
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:ray_pro2
ID: 10794355
If you intension is just creation of the directory 'xxx', add this line to the body of your main( ):

mkdir(argv[1]);

--supply the directory name as the first argument in the command line following the program name, while running the program.
0
 
LVL 12

Expert Comment

by:stefan73
ID: 10822623
karana,
> popen()
popen is very similar to system, it also has a full shell:

FILE* f=popen("mkdir your_dir","r");
/* Now you can parse mkdir's stdout via freads from f. But as mkdir is mute, not much use here */
pclose(f);

You could parse mkdirs stderr by redirecting it:
FILE* f=popen("mkdir your_dir 2>&1","r");

Then you can catch errors.

Stefan
0
 
LVL 12

Expert Comment

by:stefan73
ID: 10822633
karana,
You have tons of open old questions - please close them.

Stefan
0
 
LVL 1

Expert Comment

by:fyf7262284
ID: 10934795
ok!the function of "mkdir" is right to you!
"man 2 mkdir"
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question