![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| unix awk/sed program | mnnarendra | UNIX for Advanced & Expert Users | 4 | 03-26-2008 06:00 AM |
| UNIX program? | threewingedfury | UNIX for Dummies Questions & Answers | 1 | 02-05-2008 11:15 AM |
| How do i run a program while in Unix?.... | Corrail | UNIX for Dummies Questions & Answers | 4 | 10-31-2005 10:51 AM |
| Help with UNIX Program | brand1m | UNIX for Dummies Questions & Answers | 7 | 02-28-2005 04:55 AM |
| running a c/c++ program in unix | kray | High Level Programming | 2 | 07-12-2002 12:25 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hey Guys,
Does anyone have a copy of a c-program which saves/writes files to a sub-directory within the home directory which uses the prototype::: save (char* filename, char* directory_name)::: if at all possible, could share that syntax with me please. Thanx much..... Peace... |
| Forum Sponsor | ||
|
|
|
|||
|
#include<stdio.h>
#include<sys/types.h> #include<unistd.h> #include<fcntl.h> #include<dir.h> void save(char*, char*); void save(char *fstr, char *dstr) { char *str; int fd; char buf[100]; str = getcwd(dstr,100); if((strcmp(str,"./"))==0) { mkdir("./dstr"); } else { fd = open(fstr,O_RDWR,0); read(fd,buf,O_RDONLY,0); if(!read) { exit(0); } chdir("./dstr/"); write(fd,buf,O_RDWR,0); } } void main(){ /* pass the path of the current working directory as the second parameter*/ save("mani.txt","./manikumar/Mani"); } please check the code and run it... you may get your problem solved.... Mani... |