|
himangshuS wrote: char *str="abc";
fun(str);
cout<<str;
.
.
fun(char *str)
{
str="gggg" ;
}
but="" its="" still="" showing="" abc...why?
now="" if="" i="" change="" the="" function="" definition="" to="" as="" follow
fun(char="" ;
}<="" blockquote="">
You are altering the pointer value that is passed into fun. Like all other value parameters, that updated value is not passed back out to update the thing whose value you passed in.
If fun was change to either of these, then you could alter the pointer. But
fun(char*& str)
{
str="ggg";
}
fun(char** str)
{
(*str)="ggg";
}
Hopefully the string literal "ggg" will stick around outside the scope of fun.
You could alter the string that str points at using this:
fun(char* str)
{
strcpy(str, "ggg");
}
But I really don't think that's safe either, as (in this case), str points at a string literal, which is likely to reside in read-only space.
I see you're using STL streams...why not go the next step and use STL strings as well. Then you can forget the division between pointer values and what they point at. See the code below - str is obviously a value, would you expect it to be updated by this function?
fun(std::string str)
{
str = "ggg";
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks for all your replies
Thank you very much
-----------------------------
I am a beginner
|
|
|
|
|
himangshuS wrote: fun(char *str)
...
Now if I change the function definition to as follow
fun(char *str)
They look the same.
"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
|
|
|
|
|
The function code looks different. He's copying 4 characters into string in one version and 3 in another.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
If you need to change the original string content, then you need something like:
char str[]= "abc";
void fun(char str[])
{
strcpy(str, "ggg");
}
Of course such a method is pretty unsafe (no boundary check).
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]
|
|
|
|
|
How to extract features of characters in hindi character pattern recognition
modified on Monday, June 8, 2009 7:32 AM
|
|
|
|
|
i don't think anybody can give you a book on the topic you asked for.
|
|
|
|
|
Your query is vague. Please explain a little more so that people here can understand better.
|
|
|
|
|
I saw an effective approach a few years ago that divided the character into a grid, then computed the average (over the given samples) and standard deviation of each grid cell.
Different characters will have different distributions, and the standard deviation will give a measure of how reliable each value is.
In the example I saw, discriminant analysis was used to identify characters from the grid values.
|
|
|
|
|
code for recognising character pattern in vc++
|
|
|
|
|
See [^].
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]
|
|
|
|
|
|
prerananit wrote: code for recognising character pattern in vc++
UINT RecognisePattern(LPVOID p)
{
}
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I would expect
BOOL MyMFCFunkyClass::OnRecognisePattern(const CString & szTextWithPossiblyHiddenPattern)
{
}
From you...
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]
|
|
|
|
|
Well, I felt like providing a generic, cross-platform solution today.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Cross platform? UINT & LPVOID ? Surely you're Joking, Mr. Subramanian!
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]
|
|
|
|
|
That may pull a tough one on the OP. He may post a query asking how to port LPVOID to Linux.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Rajesh R Subramanian wrote: He may post a query asking how to port LPVOID to Linux.
You mean it's not a Linux Pointer?
"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
|
|
|
|
|
DavidCrow wrote: You mean it's not a Linux Pointer?
Yeah, it is a Long Playing VOID, indeed.
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]
|
|
|
|
|
Hi all,
In My application before starting Worker thread i m using CWaitCursor but its not displayed.
even i try it inside of Worker thread but its not working here also.
so please tell me how can i use CWaitCursor in Worker thread.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
There's a flaw in your logic here. If you compute things in a worker thread, it means that your UI will still be responsive. So why do you want to display a wait cursor ?
|
|
|
|
|
Actually i done calculation in worker thread and display sum result on modelless dialog box that show on Main dialog box,so i want to display wait cursor here .
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
You can do a BeginWaitCursor / EndWaitCursor .
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Let the worker thread work and the UI thread handle the UI: setting the cursor is part of the UI.
Steve
|
|
|
|
|
I have handlw to that window
Trioum
modified on Friday, June 12, 2009 2:03 AM
|
|
|
|