Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Pointer

Posted on 2002-05-28
2
Medium Priority
?
228 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 200 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

916 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