473,386 Members | 1,721 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,386 software developers and data experts.

help me to save a file in desured location

I'm writing a program to copy the contents of one file to another one. it working fine. But the problem is it saving the new file in the same location only. I dont know how to save the file to a differnet location. if i want to save the file to a different location( for example i'm currently working in C:\ and want the new file to be saved in d:\xxx\), what i have to do?
please help me
Nov 18 '06 #1
6 1750
horace1
1,510 Expert 1GB
I'm writing a program to copy the contents of one file to another one. it working fine. But the problem is it saving the new file in the same location only. I dont know how to save the file to a differnet location. if i want to save the file to a different location( for example i'm currently working in C:\ and want the new file to be saved in d:\xxx\), what i have to do?
please help me
when you open the output file you specify the path to the target directory, e.g. to open d:\xxx\myfile.txt
Expand|Select|Wrap|Line Numbers
  1. pFile = fopen ("d:\\xxx\\myfile.txt","w");
  2.  
you need the escape character \ before the \ speperator
Nov 18 '06 #2
Thank you for your timely help.
Another thing that i want to know is, can we run an .exe file through a c program?
That is we are running a C program. On the Run time at a particular place i want to make an ".exe" file to run. How Can i do this? Is this Possilbe?
Nov 23 '06 #3
horace1
1,510 Expert 1GB
Thank you for your timely help.
Another thing that i want to know is, can we run an .exe file through a c program?
That is we are running a C program. On the Run time at a particular place i want to make an ".exe" file to run. How Can i do this? Is this Possilbe?
The function system (available under UNIX and many other systems) has a single parameter, a command line exactly as typed at the keyboard (without the newline), e.g. to list all .c files:
Expand|Select|Wrap|Line Numbers
  1.     system("dir *.c");                                         /* call system */
  2.     printf("parent program resumed");
  3.  
The parent process is suspended and the command line dir *.c is passed to the command interpreter which, assuming all is well, executes the dir command. When the command interpreter terminates, the parent process is resumed with system returning the return code from the command processor.
Nov 23 '06 #4
Thanks For your timely help. But i think im not clear in my question.
now i ask it very clearly. This is my problem: Im running a C program. during the program i want to open a media player's EXE file. After opening the program should go on running and the media player should run on another track. There should not any relation between the program execution and the application that was opened by the program, after opening that. the only work for the program should be that, it should open the desired file and should go on in its way.... Is this possible.?
Nov 24 '06 #5
horace1
1,510 Expert 1GB
Thanks For your timely help. But i think im not clear in my question.
now i ask it very clearly. This is my problem: Im running a C program. during the program i want to open a media player's EXE file. After opening the program should go on running and the media player should run on another track. There should not any relation between the program execution and the application that was opened by the program, after opening that. the only work for the program should be that, it should open the desired file and should go on in its way.... Is this possible.?
If you were using the command prompt what would the command be to play a track?

If the command was
player track1

the C function call to run player.exe concurrently with the parent program would be
Expand|Select|Wrap|Line Numbers
  1.     int pid=spawnlp(P_NOWAIT,"player","player","track1",NULL);
  2.     if(pid < 0) printf("spawnlp fail %d\n ", pid);
  3.     else        printf("spawnlp pid %d\n ", pid);
  4.  
The parameters are:
1. mode: which indicates the state the parent process should take when the child is invoked, e.g. P_WAIT parent waits for child to terminate, P_NOWAIT parent and child run concurrently
2. filename of the command (i.e. player.exe in the above example)
3. subsequent parameters are the command and command line parameters to be passed to the child process (as in the parameter argv[] passed to main())

spawnlp() returns -1 for error or the process ID of the child process

Note that not all compilers have spawnlp() - the following worked OK with DEV-C++ using the GNU gcc compiler under Windows
Expand|Select|Wrap|Line Numbers
  1. //  test spawnlp() function to spawn a process
  2.  
  3. #include <stdio.h>
  4. #include <process.h>
  5. #include <time.h>
  6.  
  7. int main(void)
  8. {
  9.     // spawn process player with parameter track1
  10.     int pid=spawnlp(P_NOWAIT,"player","player","track1",NULL);
  11.     if(pid < 0) printf("spawnlp fail %d\n ", pid);   // error
  12.     else        printf("spawnlp pid %d\n ", pid);    // OK
  13.     while(1)           // loop printing X to display every 5 seconds
  14.       { 
  15.          clock_t start_time, cur_time;
  16.          start_time = clock();
  17.          while((clock() - start_time) < 5 * CLOCKS_PER_SEC) {}
  18.          printf("x");
  19.        }
  20.     getchar();
  21.     return 0;
  22. }
  23.  
Nov 24 '06 #6
Thanks a lot for your timely help.
Nov 28 '06 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: martingerber | last post by:
Hi, I have the following script (javascript in html document): <html> <head> <meta http-equiv="content-type" content="text/html;charset=ISO-8859-1"> <title>Standort Speichern</title>
5
by: Edwinah63 | last post by:
Hi everyone, i was wondering if anyone else had observed this and if there is any workaround or patch. i have some screens (an mdi child forms) with the buttons &Add, &Edit, &Save and E&xit,...
6
by: cj | last post by:
Lets just take this example I'm looking at now. I'm looking at the help screen titled .NET Framework Class Library FolderBrowserDialog Class . It gives an example at the bottom that begins with:...
1
by: PeterPr | last post by:
I need a routine that will step through a text file of consistent structure and, based on the content of each line, construct and save another text file. Outline of the project is as follows: 1....
1
by: treelife | last post by:
I'm getting and internal server error when | run the following mod_python script. I am actually trying to run Django. Script: from mod_python import apache def handler(req):...
1
by: Hoopster | last post by:
Here is my form that I''m having problems with. I just can't get an e-mail ??? <p><b class="yellow">Contact Us</b></p> <form action="FormToEmail.php" method="post"...
13
by: Marc | last post by:
The first part of the below writes the name and location of all buttons on a from to a text file. The second part reads that information back in and recreates the buttons. My problem is reading...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
1
by: chennaibala | last post by:
can any one send me mutiple image upload program and save the file name with extension in mysql table.we must cheak uploaded file type like bmp or any image file while uploading. i develop...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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,...

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.