Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Pointer

Posted on 2002-05-28
2
Medium Priority
?
226 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

722 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