![]() |
|
|
|
#1
|
|||
|
|||
|
maybe you could try the following routine to search for the '.' from the end of the filename:
Code:
char Filename[]= "c:\\path\\file.ext";
char *BaseFileName;
strrev(Filename);
BaseFileName = strstr(Filename,"."); // search for the '.'
if (BaseFileName){
BaseFileName = (char*)(BaseFileName+1); // exclude the '.'
strcpy(Filename,BaseFileName);
}
strrev(Filename);
strcat(Filename,".bak\0");
well of course there are still a bunch of ways to implement this. anyways, hope this helps... |
|
#2
|
|||
|
|||
|
Quote:
fnsplit() , fnmerge() i think its in dir.h splitpath() , makepath() defined in stdlib.h these all take care to find . on thier own all you need to give is buffers for specific paths and then just switch what you dont with what you need and compose back |
|
#3
|
|||
|
|||
|
Dear condzero,
Hi, Thanks for your help and reply. But there is still a problem for me that I couldn't manage it. Would you please let me know how to OPEN A FILE FOR LOGGING OUTPUT IN ANALYZE MODE? Which function(s) do you use to OPEN A FILE FOR LOGGING OUTPUT IN ANALYZE MODE? That would be great if you can discuss the case a bit. I look forward to hearing from you. Also thank anybody else who has spend time to answer to this topic to bring some help to the point. Regards, Zest. |
|
#4
|
|||
|
|||
|
Hi Zest,
Not sure what you mean by "Analyze Mode". In my example, I open a file with the parameter "wt" (Write, text mode). Then I simply create my output: Code:
char b[1024];
unsigned int o = 0; //Loop counter
FILE * pFile;
pFile=fopen("myfile.txt","wt"); // open for write text mode
// Use a loop and print your output, or just keep appending data to a buffer
then print the entire buffer (Note: Use of new line char n)
LOOP:
sprintf( b, "Some text\n")
fputs (b,pFile); // or possibly fwrite (b , 1 , 80 , pFile); (where 80 is the
length of your text, not sure which way is more applicable as I generally
use the code below)
...
//or
for ( o = 0; o < strlen(b); o++ )
{
putc(b[o], pFile);
}
// CLOSE THE FILE.
fclose (pFile);
Perhaps others can elaborate more. cheers. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|