473,396 Members | 1,724 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,396 software developers and data experts.

C++ dealing with strings

I am doing a program that I have to type 2 Customers name, match the customers name with each other, and how letters is in there. So far I have is:

#include <iostream>
#include <string>
using namespace std;

int main()
{
string cust1fullname, // declare a string object
cust2fullname,
cust1lastname,
cust1firstname,
cust2lastname,
cust2firstname;
int c, value;

cout << "Enter cust1first name: ";
cin >> cust1firstname;
cout << "Enter cust1last name: ";
cin >> cust1lastname;
cout << "Enter cust2first name: ";
cin >> cust2firstname;
cout << "Enter cust2last name: ";
cin >> cust2lastname;

getline(cin, cust1fullname);
getline(cin, cust2fullname);

cout << "The string just entered is: "
<< cust1fullname;
cout << "The string just entered is: "
<< cust2fullname;

cout << "The number of characters in cust1full name is " << value << endl;
cout << "The number of characters in cust2full name is " << value << endl;


cust1lastname = cust1fullname.substr(c+1,99);
cust1firstname = cust1fullname.substr(c+1,99);
cust2lastname = cust2fullname.substr(c+1,99);
cust2firstname = cust2fullname.substr(c+1,99);

cout << "Your cust1last name is " << cust1lastname << endl;
cout << "Your cust1first name is " << cust1firstname << endl;
cout << "Your cust2last name is " << cust2lastname << endl;
cout << "Your cust2first name Is " << cust2firstname << endl;

return 0;
}




I NEED HELP!!
Dec 10 '06 #1
1 1114
DeMan
1,806 1GB
A string is a stream of characters, terminated by a null pointer ('/0');

You can find the length of a String by looking for the null terminator. You can also compare strings by iterating through them one character at a time....
Dec 10 '06 #2

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

Similar topics

17
by: Douglas Alan | last post by:
Is there a canonical way of iterating over the lines of a file that are null-separated rather than newline-separated? Sure, I can implement my own iterator using read() and split(), etc., but...
29
by: Tom wilson | last post by:
I can't believe this is such an impossibility... I have an asp.net page. It accepts data through on form fields and includes a submit button. The page loads up and you fill out some stuff. ...
1
by: Slain | last post by:
I am a beginner and have some confusion with respect to pointers and strings. It seems that the pointers with dealing with integer arrays behave differently, as opposed to strings. Can some one...
3
by: sophie_newbie | last post by:
Hi, I want to store python text strings that characters like "é" "Č" in a mysql varchar text field. Now my problem is that mysql does not seem to accept these characters. I'm wondering if there...
4
by: Deckarep | last post by:
Hey everyone, Is there a more elegant or cleaner way of accomplishing the following null check? List<stringmyString = null; //Purposely null list of strings to show the example XElement...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.