|
-
Oct 26th, 2001, 02:45 PM
#1
Thread Starter
Addicted Member
strcat() *Answered alredy thanks
Code:
POINT pnt;
char *cTitle, *cX, *cY;
char cXBuffer[20], cYBuffer[20];
GetCursorPos(&pnt);
_ltoa(pnt.x,cXBuffer,10);
_ltoa(pnt.y,cYBuffer,10);
cTitle = "Current mouse postion is: ";
SetWindowText(hwnd,cTitle);
I am trying to learn C++, and all this pointer sh*t is killing me
i want to concat together a Title for my app in a timer and chage it every half second or so
Code:
strcat(cTitle, cXBuffer);
strcat(cTitle, ", ");
strcat(cTitle,cYBuffer);
the above code blows up and debug takes me into the string.h to debug strcat() yeah like i'm that good yet its assembly i barly know what assembly looks like anyway i know it goes boom because of cXBuffer and cYBuffer but how do I fix this?
Thanks
Last edited by ZanM; Oct 26th, 2001 at 03:34 PM.
Magiaus
Visual Basic 6.0 SP5
Visual C++ 6.0 SP5
The only sovereign you can allow to rule you is reason.
-
Oct 26th, 2001, 03:05 PM
#2
Code:
POINT pnt;
char cTitle[128], *cX, *cY;
char cXBuffer[20], cYBuffer[20];
memset(cTitle,'\0',sizeof(cTitle);
GetCursorPos(&pnt);
_ltoa(pnt.x,cXBuffer,10);
_ltoa(pnt.y,cYBuffer,10);
strcpy(cTitle = "Current mouse postion is: ");
strcat(cTitle, cXBuffer);
strcat(cTitle, ", ");
strcat(cTitle,cYBuffer);
SetWindowText(hwnd,cTitle);
I'm typing and can't see what I'm getting - watch typos.
-
Oct 26th, 2001, 03:33 PM
#3
Thread Starter
Addicted Member
here is the code minus typos
Code:
POINT pnt;
char cTitle[27];
char cXBuffer[20], cYBuffer[20];
memset(cTitle,'\0',sizeof(cTitle));
GetCursorPos(&pnt);
_ltoa(pnt.x,cXBuffer,10);
_ltoa(pnt.y,cYBuffer,10);
strcpy(cTitle, "Current mouse postion is: ");
strncat(cTitle, cXBuffer,strlen(cXBuffer));
strncat(cTitle, ", ",strlen(", "));
strncat(cTitle,cYBuffer,strlen(cYBuffer));
SetWindowText(hwnd,cTitle);
Magiaus
Visual Basic 6.0 SP5
Visual C++ 6.0 SP5
The only sovereign you can allow to rule you is reason.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|