anyone help me with this

Write a program that asks the user to enter his full name. The program should display first name and last name.
full name is 3 names

#include <iostream>
#include <string>
using namespace std;
void main()
{
string full, first, mid, last;
cout << "enter full name" << endl;
cin >> full;
first = full.substr(0, ' ');
cout << "first name is " << first<<endl;
//i cant complete this part
last = full.substr();
cout << "lsst name is" << last << endl;
}
First you shouldn't use cin>>full if you want the user's full name. If the name is John A. Doe your full would read up to the first white space, which is John.

Try using getline(cin,full). You can use the member function find in the string library to get the position of the white spaces and then use substr to get the substrings of the name
Last edited on
can you tell me how to use substr to get the last name?
closed account (48T7M4Gy)
http://www.cplusplus.com/reference/string/string/substr/
CAn any one help to create DLL which accepts strings type and returns strings too. For the following code why I always get 1 no matter how big string I pass to the function.

1
2
3
4
5
6
7
8
9
10
11
12
  // TestDll.cpp : Defines the exported functions for the DLL application.
//

#include "stdafx.h"

int  __stdcall FnString(char* inmsg)
{
	int lSTR = strlen(inmsg);

	return lSTR;
}
@kjaved8
Can any one help to create DLL which accepts strings type and returns strings too. For the following code why I always get 1 no matter how big string I pass to the function.

You should create your own thread to better describe your problem, do not hijack another person's thread.
closed account (48T7M4Gy)
@kjaved8 Perhaps you might like to create a new thread instead of using this on. there's a better chance you'll get your problem addressed that way.
@kotori
@kemort

For two days I am trying to create new topic for my issue but may be this site has some bug or I dont have permission to start new topic. When ever I try to start new topic I get a white page.
@kjaved8: I had the same problem couple of months back, reported it and nothing happened and had to create a new a/c

edit: btw it happened pretty much on the day i'd created my previous a/c and so didn't have enough time that i'd create a nuisance and get my a/c blocked ;))
Last edited on
Topic archived. No new replies allowed.