Thread: String -> unsigned char array conversion....

  1. #1
    SublicK
    Guest

    Question String -> unsigned char array conversion....

    How could you convert a string into a unsigned char array?

    could I use:

    Code:
    string ReadString;
    usigned char ReadChar[100];
    
    getline(File1,ReadString);
    sprintf(ReadChar,"%i",ReadString);
    but what would I use instead of "%i"
    ???

  2. #2
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    unsigned char* ptr = (unsigned char*)ReadString.c_str();

    will work if you don't need to modify the unsigned char*. If you need to modify it then you'll have to allocated storage a copy the contents into an array.
    zen

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. char Handling, probably typical newbie stuff
    By Neolyth in forum C Programming
    Replies: 16
    Last Post: 06-21-2009, 04:05 AM
  2. Calculator + LinkedList
    By maro009 in forum C++ Programming
    Replies: 20
    Last Post: 05-17-2005, 12:56 PM
  3. ANY BODY WILLING TO HELP ME WITH Microsoft Visual C++
    By BiG pImPiN fOoL in forum C++ Programming
    Replies: 12
    Last Post: 11-04-2001, 06:03 PM
  4. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 05:26 PM