string::operand+ usage problem (with WIN32 data types)

This is a discussion on string::operand+ usage problem (with WIN32 data types) within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by flashbaz-pi But that's not last! I want this metMetin as an integer also. Is there any function ...

  1. #16
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,413
    Quote Originally Posted by flashbaz-pi View Post
    But that's not last! I want this metMetin as an integer also. Is there any function to do this? Of course must be... But I couldn't find
    boost::lexical_cast.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  2. #17
    Registered User flashbaz-pi's Avatar
    Join Date
    Nov 2008
    Posts
    7
    Quote Originally Posted by tabstop View Post
    Actually, reading this again, you've bollixed the call to GetWindowText; so that is what is crashing when you try to write to New Jersey, or wherever metMetin happens to be pointing. You must have actual space on the other end of the pointer metMetin (via malloc/new and friends) before calling the function.
    I didn't understand what did you mean exactly. Where I will make this and how? I tried, I tried, I tried but couldn't use malloc :'(

  3. #18
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,413
    Quote Originally Posted by flashbaz-pi View Post
    I didn't understand what did you mean exactly. Where I will make this and how? I tried, I tried, I tried but couldn't use malloc :'(
    Code:
                        metKrkSys = GetWindowTextLength(hMet);
                        GetWindowText( hMet, metMetin, metKrkSys+1);
    metMetin is a pointer and its allocated size is ... 0!
    You must allocate space before using a pointer! http://cpwiki.sourceforge.net/Common...kes_and_errors
    Do this with new, not malloc.
    And then do not forget to free it.

    Code:
    metMetin = new char[hMet];
    ...
    delete [] metMetin;
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. xor linked list
    By adramalech in forum C Programming
    Replies: 23
    Last Post: 10-14-2008, 10:13 AM
  2. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  3. Replies: 4
    Last Post: 06-14-2005, 05:45 AM
  4. [question]Analyzing data in a two-dimensional array
    By burbose in forum C Programming
    Replies: 2
    Last Post: 06-13-2005, 07:31 AM
  5. Server recv data problem! Please help!
    By hyaku_ in forum Networking/Device Communication
    Replies: 15
    Last Post: 01-28-2005, 01:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21