Results 1 to 5 of 5

Thread: Data type conversion

  1. #1

    Barcode Data type conversion

    Hey


    I am trying to split a string depending on the delimiter .

    The function tat splits require a string input so iwas splitting a sample string ,but now i need to split the TCHAR[] , so i thought the better way is to convert TCHAR into string and give it as a input for the function tat splits the string.


    So is there anybody really help me to solve this issue .

    Regards
    Venkatesh.

  2. #2
    1,839
    posts
    Registered User
    not sure i totally understand your question. I think your trying to convert a char array to a string
    but you could do something like

    char myCharArray[] = "bobs , world, susanna";
    string myString = new string(myCharArray); // I think should work if not try looping through the char[]

    for(int i = 0 ; i < strlen(myCharArray);i++){
    myString += myCharArray[i];
    }

    to convert from string to char*[]
    you can do

    myString.c_str();

  3. #3
    Thanks for the reply .

    but i think it will not serve my purpose


    i will paste the piece of code wat i was trying with
    static TCHAR tcStr[ 1024 ]
    int num = StringUtils::SplitString("hello&hai&how&r&u&","&", results, true);
    the above line splits the String depending on the delimiter '&' .
    but instead of that sample string i need to split tchar----tcstr .
    when iuse tat directly to split it is showing the error,..


    error C2664: 'StringUtils::SplitString' : cannot convert parameter 1 from 'TCHAR [1024]' to 'const std::string &'
    1> Reason: cannot convert from 'TCHAR [1024]' to 'const std::string'


    can u please give me a solution for this.

  4. #4
    hey ..

    anyone there to help me as i want this to be implemented in my project.
    regards
    venkateshN

  5. #5
    you need to use std::basic_string<TCHAR> instead of std::string.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012