• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Reply to: LPSTR to DWORD?

Collapse

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  • You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
  • You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  • If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Previously on "LPSTR to DWORD?"

Collapse

  • Guest's Avatar
    Guest replied
    Re: re

    First satisified customer in ages - other than the wife - so keep it coming.

    Leave a comment:


  • Guest's Avatar
    Guest replied
    re

    cheers O.H.

    Leave a comment:


  • Guest's Avatar
    Guest replied
    xog

    I think fundamental failure to understand the data types.

    he needs to go read a decent intro to c++

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Re: Seriously?

    Still don't understand what he's on about. DWORD="Two" not = 2?. Does that mean highest byte is 'T'? etc? I must be thick. Anyhow you could cast char pointers and concat as OH says.

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Seriously?

    I'm still not sure whether to take this seriously but what the heck!

    C implements "strings" using char arrays with the end of the string flagged by a null (i.e. = 0). So create the char array of the necessary length and populate with the source pair.

    /* start */
    #include <string.h>
    #include <stdio.h>

    char *string1 = "one";
    char *string2 = "two";

    char* combination = (char*) malloc(strlen(string1) + strlen(string2) + 1);

    strcpy(combination, string1);
    strcat(combination, string2);

    /* use combination in some way */
    printf("%s\n", combination);

    /* get rid off when finished with */
    free(combination);

    /* end*/

    There are many variations on the above but should give you some pointers. Whatever you do though don't use DWORDs because they are not appropriate as pointers to data. Using LPSTRs is probably fine.

    Life can be even easier if you use the C++ String class.

    /* start */
    #include <string>
    #include <iostream>

    using namespace std;

    string string1("one");
    string string2("two");

    string combination(string1+string2);

    /* use combination in some way */
    cout << combination << endl;

    /* end */

    No need necessarily for new() & delete() because C++ allows declaration of variables at any point in function.

    Could give you the java version but Microsoft and java don't really mix. Somebody else can give you the C# which probably looks same as C++ variant.

    Ok, now tell me I've been had!

    Leave a comment:


  • Guest's Avatar
    Guest replied
    re: F WORD

    "Re question agree don't know what append really means here do you mean end up with what can be used as an array of DWORD? Giss example."


    I want to treat an instance of LPSTR & and an instance DWORD as if they where 2 bits of string and attach them. The resultant variable should be a DWORD.

    eg.

    LPSTR = "one"
    DWORD = "two"

    DWORD="onetwo"

    i guess it should be straightforward

    Leave a comment:


  • Guest's Avatar
    Guest replied
    This ezboard thing

    is total tulipe !!!>:

    Leave a comment:


  • Guest's Avatar
    Guest replied
    dword etc.

    itoa

    Leave a comment:


  • Guest's Avatar
    Guest replied
    dword etc

    Just to add an agreement with OH and xoggoth. I didn't understand what is being done either.

    not being M$ I dont know how LPSTR / DWORD are. I guess a dword is 4char ? is lpstr the same size ?
    If you append then you end up with something larger...

    You haven't helped your case with your previous questions and your responses to people questioning what you are doing/what your abilities are. which isn't a good idea when you are asking for help. especially given that some questions could be answered by rtfm

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Re: i haven't

    I always do all that crappy LPSTR, CString
    HWnd, CFile, CDoc, DDX etc. MFC bolloxy stuff for the UI and then at earliest opportunity I convert the user entries into good old C and continue happily using fopen and fread and char* and int and stuff in the technical bits.

    My VC++ code resembles a modern house in which you go through the front door and immediately decend into a victorian coal cellar full of ancient things that time mercifully forgot.

    Re question agree don't know what append really means here do you mean end up with what can be used as an array of DWORD? Giss example.

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Re: i haven't

    I think you will find that nobody understands your question.

    The word "append" implies you possibly want a structure whereas wanting a DWORD at the end smacks of bit wise and or or.

    So try rephrasing the question and you might get an answer. Somebody like ScotsPine is your man but, as his comment the other day implied, he does not know whether to take your questions seriously or not. Ask clear thought out questions and you might get some help.

    Another thing, when you complain about C and C++ data types make sure you know what you are complaining about. There are a very simple set of native data types or primatives - char, short, int, long, float, double - which are easy to learn, whereas, in the Microsoft (spit) world there are huge numbers of typedef'ed data types such as DWORD and LPSTR. Somebody on here might be able to give you a potted history regarding Microsoft's need to complicate matters and the beauty of hungarian notation. Probably something to do with Intel chips and memory models.

    Leave a comment:


  • Guest's Avatar
    Guest replied
    i haven't

    i haven't please help.

    ...mumble...C++ with its stupid variables..grumble

    why cant it just be string? or can it?

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Re: ah

    He sees the light!

    Leave a comment:


  • Guest's Avatar
    Guest replied
    ah

    Leave a comment:


  • Guest's Avatar
    Guest started a topic LPSTR to DWORD?

    LPSTR to DWORD?

    In C++, what I want to do is append a DWORD with a LPSTR and get the composite varaiable to be a DWORD. Could anyone help?

    cheers
Working...
X