Solved

Pointer

Posted on 2002-05-28
2
212 Views
Last Modified: 2010-04-02
I handling WM_KEYDOWN messege. I have char *in_text. When
I typing something I want in_text to expand.

P.S. I bought book but I didn't recived it yet. So, I don't know much about pointers but I want my program working today.

Sorry for my English.
Tnx.
0
Comment
Question by:rv_man
2 Comments
 
LVL 1

Expert Comment

by:srithi
ID: 7041157
why an array ? take CString object instead.
its easy with this object than with an array;
0
 
LVL 3

Accepted Solution

by:
MDarling earned 50 total points
ID: 7041250
WM_KEYDOWN is probably not the place to do this.

what about WM_CHAR?

as srithi said - easier to use a CString unless you aren't using MFC of course.

if you arent then...

either make in_text point to a buffer big enough for your needs

char in_text[1000] or something.

or do something like the following...

assumes in_text is dynamically allocated

char* tmp = new char[strlen(in_text)+2];

strcpy(tmp,in_text);
tmp[strlen(in_text)]=c; // where c is the new char
tmp[strlen(in_text)+1]=0; // null terminate

// delete old in_text string
delete [] in_text;

// make in_text same as tmp
in_text=tmp;

note - this isn't exactly efficent.

Regards,
Mike.


0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now