|
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;
|
|
|
|
|
wbgxx wrote: ...but the first function is error...
Which means what exactly?
wbgxx wrote: ...I don not know why...
Have you used the debugger to step through the code to find out why?
"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
|
|
|
|
|
Oh,I don not do this,sorry! I am freshman and does not use the debugger to step through the coder
|
|
|
|
|
hello, i need help on this: the error i get is: error C2440: '=' : cannot convert from 'double' to 'class _variant_t *' on this line:
Filtered_Average[ik] = filtered_sum/95;
the portion of the code is:
vector<_variant_t*> Filtered_Average(9990);<br />
for(k = 0; k < Filtered_Average.size(); ++k)<br />
{<br />
Filtered_Average[k] = new _variant_t();<br />
} ......
<br />
for (int ik = 1; ik<=N; ik++)<br />
{<br />
double filtered_sum = 0.0;<br />
<br />
for (int jk= 1; jk<=N2; jk++) <br />
{<br />
filtered_sum = filtered_sum + (double)results2[ik][jk];<br />
}<br />
<br />
Filtered_Average[ik] = filtered_sum/95;<br />
}
|
|
|
|
|
_variant_t& operator=(double dblSrc);
is valid, so you can convert from double to _variant_t. So, your problem is your trying to make a pointer equal a double.
Maybe:
*(Filtered_Average[ik]) = filtered_sum/95;
?
I'd also question the 95... if you know N2 = 95, then you don't need N2. If you don't know, then you can't use 95...
Iain.
I have now moved to Sweden for love (awwww).
|
|
|
|