![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 | |
|
Newbie
Join Date: May 2006
Posts: 18
Rep Power: 0
![]() |
Change the name of output file
Hi All,
I have a program which takes a file as input and generates a output file with name FILExxx. The name of output file is hardcoded, and the name is same, whatever inputfile may be. What I want is, if the input file is test, the output file should be named test_new, If the input file is myprog, the output file should be named as myprog_new. Quote:
Thanx jazz |
|
|
|
|
|
|
#2 |
|
Professional Programmer
|
Take the whole name of the input file, and append "_new" to the end of it. Use strcat().
__________________
The world's first athletic computer geek! The home of PrProgramsStudios How not to post a question: <-- Please don't reply |
|
|
|
|
|
#3 |
|
Guest
Posts: n/a
|
Use strcat.
char * strcat ( char * dest, const char * src ); It appends src string to dest string. The terminating null character in dest is overwritten by the first character of src. The resulting string includes a null-character at end. Parameters. dest Pointer to a null-terminated string with enough space allocated to contain both src and dest. src Null-terminated string to append. Return Value. dest is returned. Portability. Defined in ANSI-C. Example. /* strcat example */
#include <stdio.h>
#include <string.h>
int main ()
{
char str[80];
strcpy (str,"strings ");
strcat (str,"have been ");
strcat (str,"concatenated.");
puts (str);
return 0;
}Output: strings have been concatenated |
|
|
|
#4 |
|
Programming Guru
![]() ![]() ![]() |
With a prefix of './' on the new filename, it will be placed in your current directory.
ex: ./myFile.txt
__________________
http://jasonpowers.net "There are a thousand hacking at the branches of evil to one who is striking at the root." |
|
|
|
|
|
#5 |
|
Newbie
Join Date: May 2006
Posts: 18
Rep Power: 0
![]() |
Thankx everyone.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|