|
|
list of "ambiguous sysmbol" errors ..
|
|
|
|
|
I'm not getting any errors. Which IDE you are using ?
Infact, I'm not getting errors on VS6 and VS8.
Can you show exact error, you are getting.
|
|
|
|
|
Unfortunately, what worked in VC++ 6.0, no longer works in VC++ 2003. I'm not sure what version your using but we have to resort to using the scope resolution operator when programming MSXML in VC++ 2003.
Comment out the using namespace MSXML2[^]
|
|
|
|
|
|
Hi all,
Is it possible to use the strncpy() function to achive the following:
FileName1.txt to FileName1.abc
I have tried the following:
<code>
int ExtensionLen;
char *ExtensionString;
ExtensionString = FileNameFromClient;
ExtensionLen = strlen(ExtensionString) - 4;
char extstring[20];
strncpy( (char*)extstring, ExtensionString, ExtensionLen );
strcat((char*)extstring,(char*)".tcp");
</code>
Just to change the extension, or is there something else I could use?
Thanx
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
If you want to do it in plain old C, here is a way:
char fileName[20];
strcpy(fileName, "FileName1.txt");
// Now change extension to ".abc"
// "Smart" coding, assumes there is a dot in the filename
strcpy(strrchr(fileName, '.'), ".txt");
OR (safer):
char * cpDot = strrchr(fileName, '.');
if(NULL != cpDot) strcpy(cpDot, ".txt");
Let the flaming begin! (I won't answer, I have work to do).
-- modified at 8:30 Thursday 16th November, 2006
Thanks, toxcct!
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
this will do if the file name contains only one '.'.
if the file is called for instance foo.test.doc, your code will fail.
|
|
|
|
|
Thanks for pointing that out. It's fixed now.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Thank you toxcct ...
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Thank you kakan for the reply, I'll try it. And I don't think this senario will happen:
file1.a.txt
Thanx again
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
Hello.
Anyhow, I've fixed it, when toxcct pointer it out to me.
I changed strchr to strrchr.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
You want to rename file , dont you?
Have you come across this code from MSDN ?
#include <stdio.h>
void main( void )
{
int result;
char old[] = "RENAMER.OBJ", new[] = "RENAMER.JBO";
result = rename( old, new );
if( result != 0 )
printf( "Could not rename '%s'\n", old );
else
printf( "File '%s' renamed to '%s'\n", old, new );
}
-- modified at 6:34 Friday 17th November, 2006
Hey , come on. Let me know reason before voting me down.
|
|
|
|
|
prasad_som wrote: char new[] = "RENAMER.JBO";
new is a reserved keyword
|
|
|
|
|
Its 'c' code .
This is header comment from MSDN for posted code,
|
|
|
|
|
prasad_som wrote: Its 'c' code
ok, now you say it, but you didn't explain it previously, so i couldn't know.
|
|
|
|
|
Thank you for the reply prasad_som.
Yes, I want to rename the file ... well kinda, the thing is I wrote a tcp/ip client - server. And the client sends a file to the server, but the server must change the extension of the file when the file transfer begins and change it back to the original extension. The thing is all the code is dynamic and file paths & extension can change... tricky ....
Thanx again
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
hmmm.
You may like to have look at this for parsing file name
basic_string::rfind ,CString::ReverseFind . Look to lst '.' character, and change it to rquired.
|
|
|
|
|
Thank you very much ... I'll check it out...
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
prasad_som wrote: Look to lst '.' character, and change it to rquired.
Or use PathFindExtension() .
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DavidCrow wrote: Or use PathFindExtension().
Very true. My 5.
|
|
|
|
|
« Programm3r » wrote: Is it possible to use the strncpy() function to achive the following:
FileName1.txt to FileName1.abc
Why not just use PathRenameExtension() ?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I wand to read file form end to the start of the file...
byte by byte...
can anyone suggest me or provide me any sample code that helps me...??????
thanks in advance...
Savcejana Sukinobavanthu
Ashok.
|
|
|
|
|
You could do it with a for loop, find the length of the file in bytes (using a while loop or otherwise)
then do a for loop but backwards
for(int i=FileLength; i>=0; i -=1) {
//Read the file i number of bytes
}
|
|
|
|
|
Why do you need to do this? I would suggest reading the file into a buffer, and then reversing that buffer. It'll be much faster this way.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|