|
yeah ,I will look it ,thank you very much
best wishes!
david zhang
|
|
|
|
|
I have checked your code, its fine and no access violation caused so far. By the way, At present your code does not check all the files available in the current directory, I changed the code like -
GetCurrentDirectory(MAX_PATH,path);
<font color='red'>strcat(path,_T("\\*.*"));</font>
WIN32_FIND_DATA findFileData;
findFileData.dwFileAttributes=FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_READONLY;
HANDLE fHandle=FindFirstFile(path,&findFileData);
Now it compares all available files with strFilename .
Just a suggestion...
|
|
|
|
|
The following may or may not address your issue, but here are some things I've noticed.
Firstly the following is pointless:
fresh888888 wrote: findFileData.dwFileAttributes=FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_READONLY;
The documentation for FindFirstFile[^] states that:
LPWIN32_FIND_DATA lpFindFileData is an out only parameter.- The search is performed strictly on the name of the file, not on any attributes such as a date or a file type (for other options, see FindFirstFileEx).
Secondly your pattern (the first parameter passed to FindFirstFile[^]) contains no wildcard. You probably mean something like this:
char path[MAXPATH];
GetCurrentDirectory(MAXPATH, path);
PathAppend(path, "*");
Steve
|
|
|
|
|
fresh888888 wrote: if(!strcmp(findFileData.cFileName,strFilename)){
strcmp() is not a boolean function, thus should not be treated like one.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
hi anshuman_,I have found result with the exception and known differently for between char* path="" to char path[255]="" ,thanks
<prex>
char * path="";
sprintf(path,"%s\\*",GetCurrentDirectory(MAXPATH,str));
it have error 0xC0000005: Access violation writing location
but it's right
char path[255]="";
sprintf(path,"%s\\*",GetCurrentDirectory
perfect...
char path[MAXPATH];
GetCurrentDirectory(MAXPATH,path)
WIN32_FIND_DATA findFileData;
char strFilename[255]="";
SYSTEMTIME stime;
GetLocalTime(&stime);
CString strTime="";
strTime.Format("%4d%02d%02d",stime.wYear,stime.wMonth,stime.wDay);
sprintf(strFilename,"%s\\report_invoice_%s%s.xls",path,dp->lineText,strTime);
HANDLE fHandle=FindFirstFile(strFilename,&findFileData);
if(fHandle!=INVALID_HANDLE_VALUE){
if(DeleteFile(strFilename)){
MessageBox(NULL,"删除文件成功","UDatabase",MB_OK);
}
FindClose(fHandle);
}
|
|
|
|
|
I confirmed that gps value changes in NMEAParserDemo Project
Did to do practice moving NMEAParserDemo Project's source to web project as it is
Value 'Ho' does not change.
I teach what did wrongly
NMEAParserDemo
web
|
|
|
|
|
rephrase or hire an interpreter.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
|
Yeah! I have just hired a detective who is helping me in figuring out where is this 'Ho' coming from.
I trust the detective as he is a direct descendant of the Sherlock Holmes dynasty...
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Hi to All,
Here I am getting an error. Breaking my head but not able to get it done. Please help me out with.
I know I have done some silly mistake,..But not able to view it
Mu code is...
char *a,*b,*temp;
a="aa";
b="bb";
while(*a!='\0')
{
*temp++ = *a++;
}
while(*b!='\0')
{
*temp++ = *b++;
}
*temp = '\0';
....
its showing error in the line...*temp++ = *a++;
Thanks in advance
|
|
|
|
|
What error do you get [Compile/RunTime]. Please provide the details
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Thnaks for your reply
I am getting an runtime error...
(Unhandled exception...Access violation)
Thanks...(anyway,..My brothers name is Anshumaan)
-----------------------------
I am a beginner
|
|
|
|
|
Ah! that may be because temp is not initialized.
Initialize it!
And believe it or not, but my brothers name is HIMANGSHU
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
thanks a lot...
About the name..that's interesting...I feel somewhat to talk personal staff in this forum. Lets not violet the rules..hehe...Could you give me Gmail Id if you dont mind.We can talk in Gtalk .
Regards,
Himangshu
|
|
|
|
|
What error? I cannot see syntactic error there. Do you allocate memory for temp?
|
|
|
|
|
I am getting an runtime error...
(Unhandled exception...Access violation)
|
|
|
|
|
You should must allocate memory for temp .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
thanks
But there is one problem. How much memory should I allocate? Since It is a program for concatenation of string...And I wont be knowing the no of characters after contcatination(ie the size of the temp) in advance.
How to go about it?
|
|
|
|
|
Well you may allocate a predefined amount of memory (on statistical grounds) and then reallocate (for instance, in C language, you may use malloc and realloc ) a bigger size if needed.
BTW: you know, there are C runtime library functions for the purpose of concatenating strings.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
yes But I wanted to implement it with my own code....So that I learn pointer concept too..
-----------------------------
I am a beginner
|
|
|
|
|
I used the following code.....No error but not giving any results
char *a,*b;
char *temp;
temp=new char[5];
a="aa";
b="bb";
while(*a!='\0')
{
*temp++ =*a++ ;
}
while(*b!='\0')
{
*temp++= *b++ ;
}
*temp = '\0';
printf("%s",temp);
-----------------------------
I am a beginner
|
|
|
|
|
That's almost the solution... , try:
char *a,*b;
char *temp, *dest;
dest=new char[5];
temp = dest;
a="aa";
b="bb";
while(*a!='\0')
{
*temp++ =*a++ ;
}
while(*b!='\0')
{
*temp++= *b++ ;
}
*temp = '\0';
printf("%s",dest);
of course you need now to generalize the code (ad remember to free dest when you no longer need it)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Oh thanks a lot...its working fine...
I have to increase my knowledge towards pointer
-----------------------------
I am a beginner
|
|
|
|
|
himangshuS wrote: I wont be knowing the no of characters after contcatination(ie the size of the temp) in advance.
Yes you can - you need to allocate strlen(A) + strlen(B) + 1 characters, where strlen is defined as follows:
int strlen(const char* s)
{
int count;
while (*(s++))
++count;
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
A code you have past here is the exact code that is in your system?
But if you have taken temp as array (char temp[XX] ) then you might get error which you told. But a code that we are sawing has no that kind of error.
Do not trust a computer...
Always check what computer is doing
regards,
Divyang Mithaiwala
Software Engineer
modified on Thursday, May 7, 2009 5:38 AM
|
|
|
|