![]() |
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 |
Take the whole name of the input file, and append "_new" to the end of it. Use strcat().
|
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 */Output: strings have been concatenated |
With a prefix of './' on the new filename, it will be placed in your current directory.
ex: ./myFile.txt |
Thankx everyone.
|
| All times are GMT -5. The time now is 12:53 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC