Exetools  

Go Back   Exetools > General > General Discussion

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 08-31-2006, 10:11
d34ddr34m3r
 
Posts: n/a
Lightbulb

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");
this should work even if the filename does not include a full path
well of course there are still a bunch of ways to implement this.

anyways, hope this helps...
Reply With Quote
  #2  
Old 08-31-2006, 14:37
JuneMouse
 
Posts: n/a
Quote:

well of course there are still a bunch of ways to implement this.
yes you can try

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
Reply With Quote
  #3  
Old 09-07-2006, 13:28
Zest
 
Posts: n/a
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.
Reply With Quote
  #4  
Old 09-09-2006, 01:01
condzero
 
Posts: n/a
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);
This produces a nice clean text file.

Perhaps others can elaborate more.

cheers.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



All times are GMT +8. The time now is 02:34.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( Since 1998 )