Solved

Pointer

Posted on 2002-05-28
2
219 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…

803 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