Solved

Pointer

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Suggested Solutions

Title # Comments Views Activity
Which IDE to use to begin C++ training? 5 65
PDF library for Delphi 2 128
C++ to C# code conversion issue 4 112
Why isn't object file created? 6 68
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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…
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 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.

840 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