Confused.. my teacher asked me to put this information into a string from an array.. here are the exact direction she had given me:
"Using the location of the space, use this and the appropriate string functions to store the first name in fname and the last name in lname (both string variables)."
The isspace function found the white space for me, and i put it in the variable 'y' as you will see in my code below. but I have no idea how to use the white space to put it the characters entered from the array into two separate string variables!
... any help would be greatly appreciated!
here is my code:
// Zachary Law Strings.cpp
#include <iostream>
using namespace std;
#include <string>
#include <iomanip>
int main()
{ int x, i,y;
char name[] = "Please enter your name: ";
char answer1 [80];
i=0;
y=0;
cout << name;
cin.getline(answer1, 79);
cout << endl;
x=strlen(answer1);
for (int i = 0; i < x; i++){
cout << answer1[i] << endl;
if (isspace(answer1[i]))
{y=y+1;}}
cout << endl << endl;
cout << setw(80) << answer1;
cout << y;
return 0;}