DLL trouble

This is a discussion on DLL trouble within the C++ Programming forums, part of the General Programming Boards category; Hi, I am using Dev-C++ and I made my first DLL. The DLL added two numbers together and returned the ...

  1. #1
    Registered User
    Join Date
    Aug 2007
    Posts
    2

    DLL trouble

    Hi, I am using Dev-C++ and I made my first DLL. The DLL added two numbers together and returned the sum. I tried to send a string and have it send it back but for some reason it just sends back nothing. Here's my code...

    dll.cpp
    Code:
    char* DllClass::String(char* string)
    {string = "Hello World";
    return string;}
    dllclient.cpp
    Code:
    int main()
    {
    char* iValue;
    char* vReturn;
    DllClass Value;
    cin >> iValue;
    vReturn = Value.Encrypt(iValue);
    cout << vReturn;
    system("PAUSE");
    }
    Keep in mind the DLL works when dealing with numbers, so I'm not sure what the problem here is... Thanks anyways.

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,801
    You can't just assign a string like that. You would need to use strcpy.

  3. #3
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,456
    cin >> iValue;

    iValue is not initialized pointer... You just asking from the cin to write the input data on some random address...
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  4. #4
    Registered User
    Join Date
    Aug 2007
    Posts
    2
    Hmm I'm sorry I don't think I understand. If you could by any chance show me the code you think I should use to get the Dll code to return the string to the exe. Thanks again :\

  5. #5
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    dll.cpp
    Code:
    std::string DllClass::String(std::string string)
    {string = "Hello World";
    return string;}
    dllclient.cpp

    Code:
    int main()
    {
    std::string iValue;
    std::string vReturn;
    DllClass Value;
    cin >> iValue;
    vReturn = Value.String(iValue);
    cout << vReturn;
    system("PAUSE");
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. non-MFC DLL with MFC app question.
    By Kempelen in forum Windows Programming
    Replies: 10
    Last Post: 08-20-2008, 07:11 AM
  2. Replies: 1
    Last Post: 09-18-2005, 09:06 PM
  3. dll communicating between each other
    By cloudy in forum C++ Programming
    Replies: 5
    Last Post: 06-17-2005, 02:20 AM
  4. DLL and std::string woes!
    By Magos in forum C++ Programming
    Replies: 7
    Last Post: 09-08-2004, 12:34 PM
  5. .lib vs .h vs .dll
    By Shadow12345 in forum C++ Programming
    Replies: 13
    Last Post: 01-01-2003, 04:29 AM

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