0

I'm just learning about character arrays. From what I understand, in C++ character arrays store a space as NULL. Is there a way I can use that to separate an array into two?

    char Full_Name[14] = {Henry Ford};

  /*how would I go about separating that into two character arrays? I have 
    an idea more or less, but surely there's something simple that I haven't 
    learned yet. */

    char First_Name[7], Last_Name[7];

    strcpy(First_Name, )
    strcpy(Last_Name, )
  • 3
    Use [`std::string`](http://en.cppreference.com/w/cpp/string/basic_string) and [`std::istringstream`](http://en.cppreference.com/w/cpp/io/basic_istringstream) with the `>>` input operator. – Some programmer dude Oct 21 '17 at 04:22
  • 1
    And please [get a good beginners book](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list), because there are some very basic misunderstandings you have. – Some programmer dude Oct 21 '17 at 04:26
  • _character arrays store a space as NULL_ no, they store space as space. –  Oct 21 '17 at 08:08
  • strcpy and char arrays are used in C. Don't do that in C++, use std::string. –  Oct 21 '17 at 08:09
  • It's for a class assignment. We're supposed to ask user for full name and input that into a char array char Full[40], and parse it into two other arrays char First[20], char Last[20]. I'm looking online for solutions. The hint on the instruction was to use strcpy(First, "xx") strcpy(Last, "yy"). From what I've been searching, looks like I can probably accomplish what I'm trying to do by using strtok(). Is this website not for students or something? Some of you guys seem upset at my question. – Carlos Herrera Oct 22 '17 at 05:46

0 Answers0