|
includeh10 wrote: If you do not have any experience about my post, please do not say it is "enough" for nothing.
If you do have the manners to say thank you, please do not post asking for help. I'll try and remember to leave you struggling in the future.
Iain.
I have now moved to Sweden for love (awwww).
|
|
|
|
|
I think that answer is enough, if your question is as mentioned above. But if you are expecting some other answer then please change the question
Величие не Бога может быть недооценена.
|
|
|
|
|
It's responses like this that keep you in the "gray." Are you this grating in person or is it just your online personification?
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
|
Hello Includeh10,
I would like to ask a few usage policy and quesions on the barcode application you developed and posted on Code Project site in Mar 2006. Could you please respond by Test E-mail?
Looking forward to hearing from you.
Best regards,
-/Madhav
|
|
|
|
|
you know if you want to use an ocx(activex) file in your project, you have to register it in your system & subsequently the others who use your program have to do that. i'm looking for a way which load activex in a .h file so we don't need to register it. can you help me?
thanks.
|
|
|
|
|
even if you use #import or the Class-Wizard to generate the wrappers, I think you still need to have registered the control
'g'
|
|
|
|
|
|
Is their any way to pass a message other than a string in a MessageBox.
And would it require casting?
|
|
|
|
|
No. Why?
You could convert the data you wish to show to a text representation and then display it in a message box.
|
|
|
|
|
What are those functions?
|
|
|
|
|
|
will you try SendMessage(...)? The parameters [WPARAM] and [LPARAM] can be set a string or other types.
|
|
|
|
|
|
I try to do this but the first function is error ,I don not know why ,could someone help me ,thank in advantage!!
void StrDelete1(char ch[], int pos,int len)
{
if (pos<0 || pos >(MAX-len))
{
printf("the string delete error!");
exit(1);
}
int i;
for (i=0; i<MAX; i++)
printf("%c", ch[i]);
char *temp = (char*)malloc(sizeof(char));
if (temp == NULL)
{
exit(1);
}
for (i=pos; i<MAX-len; i++)
{
temp = &ch[i];
free(temp);
}
printf("\n");
for(i=0; i<MAX; i++)
printf("%c", ch[i]);
}
void StrDelete2(char ch[], int pos,int len)
{
if (pos<0 || pos >(MAX-len))
{
printf("the string delete error!");
exit(1);
}
int i;
printf("\n");
for (i=0; i<MAX; i++)
printf("%c", ch[i]);
char *temp = (char*)malloc(MAX-len);
if (temp == NULL)
{
exit(1);
}
for (i=0; i<pos; i++)
temp[i] = ch[i];
for (i=pos; i<MAX-len; i++)
{
temp[i]=ch[i+len];
}
free(ch);
printf("\n");
for (i=0; i<MAX-len; i++)
printf("%c", temp[i]);
}
|
|
|
|
|
Here, you are freeing memory that the function didn't allocate:
for (i=pos; i<MAX-len; i++)
{
temp = &ch[i];
free(temp);
}
Why are you calling free there?
|
|
|
|
|
"Why are you calling free there?"
Yeah ,I only want to delete the number in the arry,Is it delete the memory in the stack??
|
|
|
|
|
No, it only releases memory allocated on the heap. To release memory on the stack you have to use assembly langauge (in which case things get complicated) or let it go out of scope (like you should).
|
|
|
|
|
void StrDelete1(char ch[], int pos,int len)
{
if (pos<0 || pos >(MAX-len)) {
printf("the string delete error!");
exit(1);
}
int i;
for (i=0; i<MAX; i++) printf("%c", ch[i]);
char *temp = (char*)malloc(sizeof(char));
if (temp == NULL) {
exit(1);
}
for (i=pos; i<MAX-len; i++) {
temp = &ch[i];
free(temp);
}
printf("\n");
for(i=0; i<MAX; i++) printf("%c", ch[i]);
}
First off, you should remove "char *temp = (char*)malloc(sizeof(char));". The allocated memory is never used, and it is never released.
To my knowledge, free() releases a block of memory, not just that at the address pointed to. Therefore what you are trying to do may not be possible. I suggest you either call free() on the array (if it is allocated with malloc()) and release it, or set the element at pos to '\0'.
Also, you are accessing memory you are trying to free at the end of the function. Do not do that.
EDIT:
Okay, I think I have figured out away to accomplish you goal. Here is a sample to get you started in the right direction (you may want to revise it):
char * DeleteString1(char * ch,int pos,int len) {
memmove(ch+pos,ch+pos+len,strlen(ch)-(pos+len));
return realloc(ch,strlen(ch));
}
modified on Wednesday, April 7, 2010 8:27 PM
|
|
|
|
|
real fine solution
i wouldnt realloc for performance reasons
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Given the sample code given, I assumed they want to release memory, which realloc would do. However, it is true that doing so is not needed unless memory is in short supply.
|
|
|
|
|
this is an complicated theme, because the memory is from a bigger block which is in a list. So it can happen that only these function cost some CPU operations but also you get fragmented memory.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Yes, down sizing the memory is problematic, but that is one more reason my sample should be revised. It was not intended to be fully functional, just showcase what could be done to get the desired results. I spent less than a minute on it so it is likely full of problems; since the enquirer is a student thinking about improve it would be good practice.
|
|
|
|
|
Yes it looks like a 'hot fix'.
And therefor makes an additional comment for that performance risk sense
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
What would you like to see ?
A possible task could be:
1) Given: "abcdef"
2) Cut: 2 characters from the position 3
3) Result: "abcf"
virtual void BeHappy() = 0;
|
|
|
|