Thread: strings!

  1. #1
    Burning in Hell! Luigi's Avatar
    Join Date
    Nov 2002
    Posts
    117

    Question strings!

    consider the following :
    string str;
    char juju[50];

    how can I put str content into juju?

    juju = str wont work for sure and strcpy neither..

    what else?

    thx luigi

  2. #2
    Registered User
    Join Date
    Dec 2002
    Posts
    103

    A small refinement

    strncpy( juju, str.c_str( ), str.length() );
    juju[str.length()] = 0;
    Have a wonderful day.... and keep smiling... you look terrific that way
    signing off...
    shiv... as i know him

  3. #3
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680

    Re: A small refinement

    Originally posted by shiv_tech_quest
    strncpy( juju, str.c_str( ), str.length() );
    juju[str.length()] = 0;
    It should be: juju[str.length()-1]

    But this is still crappy code. What happens if the length of the string is 60?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strings Program
    By limergal in forum C++ Programming
    Replies: 4
    Last Post: 12-02-2006, 03:24 PM
  2. Programming using strings
    By jlu0418 in forum C++ Programming
    Replies: 5
    Last Post: 11-26-2006, 08:07 PM
  3. Reading strings input by the user...
    By Cmuppet in forum C Programming
    Replies: 13
    Last Post: 07-21-2004, 06:37 AM
  4. damn strings
    By jmzl666 in forum C Programming
    Replies: 10
    Last Post: 06-24-2002, 02:09 AM
  5. menus and strings
    By garycastillo in forum C Programming
    Replies: 3
    Last Post: 04-29-2002, 11:23 AM