473,387 Members | 1,515 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Any insight how to solve finding a const string fullName = "..."

Dear Friends,

I will really appreciate any assistance in this particular challenge. I am pretty much new with C++ (ISO/ANSI)

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. const string fullName =  " Franklin Delano Roosevelt" 
  7.  
  8. int main( )
  9.  
  10. {
Jan 30 '07 #1
4 1406
willakawill
1,646 1GB
Hi. Love to help but I have no idea what your question is
Jan 30 '07 #2
Dear Friends,

I will really appreciate any assistance in this particular challenge. I am pretty much new with C++ (ISO/ANSI)

#Iinclude <iostream>
#include <string>

using namespace std;

const string fullName = " Franklin Delano Roosevelt"

int main( )

{
Are you getting compilation error ? Why are you including <string> ? you can try using std::string
Jan 30 '07 #3
Hi. Love to help but I have no idea what your question is
Thanks for your reply. For some reason, I have edited my question, but it did not up-date. Sorry.

here is what I am trying to accomplish:

#include <iostream>
#include <string>

using namespace std;

const string name = "John Paul Jones";

int main() {


int spacePos = name.find(' ');

string firstName = name.substr(0, spacePos);
string middleName = name.substr(spacePos + 1);



cout << firstName + ' ' << middleName << endl;

return 0;

}

My goal is to be able to show first any name that is type above the int "string const <name>= "..."

As an example, I have firstname= John, middlename = Paul and lastname = Jones.

However, the problem is that I really do not know how to go about this. So far, I have been able to obtain the first name correctly. When I request the middlename, it actually provides me both: middlename, and lastname.

Thanks so much!!
Jan 30 '07 #4
Are you getting compilation error ? Why are you including <string> ? you can try using std::string
thanks for your reply.

So far, I am not getting an error up to what I have accomplished. The issue I am having is that I really do not know how to make the three names show up on the screen correctly.

I am supposed to be able to use any given names on the const string fullname = " ";

and be able output the correct results no matter how long or short the names are.

ei:

I am trying to cout >> firstName >> middleName >> lastName >>


This is the code I have so far:

#include <iostream>
#include <string>

using namespace std;

const string name = "John Paul Jones";

int main() {


int spacePos = name.find(' ');
// int len = name.length();
string firstName = name.substr(0, spacePos);
string middleName = name.substr(spacePos + 1);



cout << firstName + ' ' << middleName << endl;

return 0;

}

Thank you for your time!! and any input in resolving this challenge.

Have a great day!
Jan 30 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Mike | last post by:
Greetings, I am writing an Intranet application in ASP.NET using VB.NET. I am obtaining the username of the user with: uName = User.Identity.Name, which is in the form of DOMAIN\username. I...
23
by: Hans | last post by:
Hello, Why all C/C++ guys write: const char* str = "Hello"; or const char str = "Hello";
5
by: Willem | last post by:
Hello I am quite hopeless and of course a newbe. The situation: Sql2k / query I would like it ot break down the following string: 2004 Inventory:Ex.Plant Farm1:1st Cut:Premium:0094
2
by: Miguel Dias Moura | last post by:
Hi, i created a dataSet in an ASP.Net page which: 1. Loads all fields from each database record. 2. Creates a new field using 2 of the existing fields: FullName = FirstName + ' ' + LastName...
2
by: Thomas Müller | last post by:
Hi, I need a way to find the names of the computers that are reachable over a network. Ideally when it is executed it should report back wich computernames are present. I have seen one...
16
by: recover | last post by:
#include <string> #include <iostream> using namespace std; class TConst { private: string con; string uncon; public:
7
by: xgngli | last post by:
Hi all! I've taken some time on learning the difference between "pointers to const variables" and "const pointer variables". The question is: in the following code, can we change the contents of...
20
by: liujiaping | last post by:
I'm confused about the program below: int main(int argc, char* argv) { char str1 = "abc"; char str2 = "abc"; const char str3 = "abc"; const char str4 = "abc"; const char* str5 = "abc";
0
by: creo | last post by:
OS: Windows XP (32 bit) NET: .Net 2.0 runtime DevEnv: VS 2008 C++ and C# I am attempting to use an unmanaged C++ library to load a managed C# assembly and hand off control. I have the following...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.