>using only simple codes like length, size, adding, and subtracting.
Loop through the string and print non-whitespace characters. When you get to whitespace, skip the whitespace, go to a new line and repeat until you get to the end of the string.
>I can't use loop or i will get a deduction
That's stupid. That's really really stupid. Feel free to tell your teacher I said that.
>and that is where i got stuck, getting the middle name by itself
You know where the middle name starts right? And you know how to find the next space, right? So what happens if you subtract the index for the next space from the index of the first letter in the middle name? It gives you the length of the middle name, which can be used as the second argument to substr.
I know where it starts but i dont know how to search for the space again
int spacePos2= fullname.find(' '); //will not find the 2nd space and that is it. how would u suggest to find it?
spacPos2 = fullname.rfind(' ');......// but i cant use .rfind to find it again or I will get a deductions. how about a way; of fullname length - (firstname + spacepos1) as a new variable and then search for the spacepos2 there?
#include <fstream> //for fıle ınput and output....
using namespace std;
string fullname="This is crazy";
int spacepos=fullname.find(' ');
cout<<"First name is "<< firstname<<endl;
cout<<"Middle name is "<<middlename<<endl;
cout<<"Last name is "<<lastname<<endl;
}// end of main