Hello,
I figured I'd make a nice program to list my contact names and phone numbers (since I keep losing my cellphone) though I have a few questions...
How would I list the strings if I wanted to be able to add contacts through the program ? Would I just have to list extra strings just in case ? I would prefer not to.
Second question
My program will list choices (A, B, and C) and get the user's input (x), telling what the program to do. I have it set up so that if the user input a, or A it would do the same thing, and same goes for the others. My problem is that if the user inputs W or something, I have an Else option, printing " come again ?" and asking for x again.
But if the user inputs W again, (or a few more times) the program just ends. I need some loop keeping the user at that state, or sending it back up to the beginning of the program.
This's what I got: -
if (x == "a" || x == "A"){
-
cout << "A list of contacts should appear" ;
-
}
-
else{
-
cout << "Pardon me? Please type that again... ";
-
cin >> x;
-
}
apparently it's not working too well : /
Yet another question... How do I wrap the above code in C++ code ? I don't see the option anywhere.
I appreciate your time
8 3527
Hello,
I figured I'd make a nice program to list my contact names and phone numbers (since I keep losing my cellphone) though I have a few questions...
How would I list the strings if I wanted to be able to add contacts through the program ? Would I just have to list extra strings just in case ? I would prefer not to.
Second question
My program will list choices (A, B, and C) and get the user's input (x), telling what the program to do. I have it set up so that if the user input a, or A it would do the same thing, and same goes for the others. My problem is that if the user inputs W or something, I have an Else option, printing " come again ?" and asking for x again.
But if the user inputs W again, (or a few more times) the program just ends. I need some loop keeping the user at that state, or sending it back up to the beginning of the program.
This's what I got: -
if (x == "a" || x == "A"){
-
cout << "A list of contacts should appear" ;
-
}
-
else{
-
cout << "Pardon me? Please type that again... ";
-
cin >> x;
-
}
apparently it's not working too well : /
Yet another question... How do I wrap the above code in C++ code ? I don't see the option anywhere.
I appreciate your time
You could use a do while loop: -
char x;
-
do
-
{
-
cin >> x;
-
}
-
while (tolower(x) != 'a' && tolower(x) != 'b' && tolower(x) != 'c');
-
// x is either 'a', 'b', or 'c'
-
Hello,
I figured I'd make a nice program to list my contact names and phone numbers (since I keep losing my cellphone) though I have a few questions...
How would I list the strings if I wanted to be able to add contacts through the program ? Would I just have to list extra strings just in case ? I would prefer not to.
Second question
My program will list choices (A, B, and C) and get the user's input (x), telling what the program to do. I have it set up so that if the user input a, or A it would do the same thing, and same goes for the others. My problem is that if the user inputs W or something, I have an Else option, printing " come again ?" and asking for x again.
But if the user inputs W again, (or a few more times) the program just ends. I need some loop keeping the user at that state, or sending it back up to the beginning of the program.
This's what I got: -
if (x == "a" || x == "A"){
-
cout << "A list of contacts should appear" ;
-
}
-
else{
-
cout << "Pardon me? Please type that again... ";
-
cin >> x;
-
}
apparently it's not working too well : /
Yet another question... How do I wrap the above code in C++ code ? I don't see the option anywhere.
I appreciate your time
Hi,
First Question:
>>>Provide more info on this
Second Question
>>>the part of code u have given is inside a while loop?
I tried something similar and it is working perfectly. -
{
-
string x;
-
cout<<"enter a value"<<endl;
-
cin>>x;
-
while(1)
-
{
-
if(x == "a" || x== "b")
-
{
-
cout<<"done ..."<<endl;
-
break;
-
}
-
else
-
{
-
cout<<"Re-enter a value"<<endl;
-
cin>>x;
-
}
-
}
-
}
-
Raghuram
Hi,
First Question:
>>>Provide more info on this
Second Question
>>>the part of code u have given is inside a while loop?
I tried something similar and it is working perfectly. -
{
-
string x;
-
cout<<"enter a value"<<endl;
-
cin>>x;
-
while(1)
-
{
-
if(x == "a" || x== "b")
-
{
-
cout<<"done ..."<<endl;
-
break;
-
}
-
else
-
{
-
cout<<"Re-enter a value"<<endl;
-
cin>>x;
-
}
-
}
-
}
-
Raghuram
I think i answered this a litle late.......
I think i answered this a litle late.......
Hehe, that's okay, I still appreciate you ! -
char x;
-
-
do
-
-
{
-
-
cin >> x;
-
-
}
-
-
while (tolower(x) != 'a' && tolower(x) != 'b' && tolower(x) != 'c');
.
I don't understand how I can assign options with this code. I'm not sure what tolower is either...
So far, I've gotten gpraghuram's solution to work pretty nicely, though I would still like to know your way of solving this problem, python ...Can you explain it to me?
Hehe, that's okay, I still appreciate you !
.
I don't understand how I can assign options with this code. I'm not sure what tolower is either...
So far, I've gotten gpraghuram's solution to work pretty nicely, though I would still like to know your way of solving this problem, python ...Can you explain it to me?
Basically, it is just a do while loop that runs until you get the value you need. If x is not either 'a', 'b', or 'c', it asks for it again. tolower() just turns the character lowercase. That avoids having to write "x != 'A'", "x != 'B'", or "x != 'C'".
Basically, it is just a do while loop that runs until you get the value you need. If x is not either 'a', 'b', or 'c', it asks for it again. tolower() just turns the character lowercase. That avoids having to write "x != 'A'", "x != 'B'", or "x != 'C'".
Ahh I see. Thanks for the help!
Hello,
How would I list the strings if I wanted to be able to add contacts through the program ? Would I just have to list extra strings just in case ? I would prefer not to.
Nobody answered my question above...
I'll try figuring this out, if not, I'll see if anyone posted a tip.
Thanks
Nobody answered my question above...
I'll try figuring this out, if not, I'll see if anyone posted a tip.
Thanks
i am not getting your question.
R u tying to maintain a list of strings?
then you can use vector<strings> and an iterator to display the strings.
Raghuram
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jason |
last post by:
I'm struggling with this email code and I'm not php freak since I'm
starting to learn php stuff. Could use some help...
It seems that I get too many parse errors all over and cannot figure
went...
|
by: Brian Henry |
last post by:
Does anyone know of a way to pull my contact lists out of exchange server
and into a VB.net application? or even a public contact list? Thanks! This
is something I need really bad, any help would...
|
by: kannan |
last post by:
Hi,
I am trying to loop through outlook contact address and display in
messagebox.
I have used following code:
Outlook._Application olApp = new Outlook.ApplicationClass();
Outlook._NameSpace...
|
by: Robert J. Bonn |
last post by:
I'm trying to set up a contact list in MS Access 97. I've looked
through a reference book and the program's help screens, but the light
bulb isn't quite coming on for me. If one of you could take...
|
by: rjbonn |
last post by:
I'm setting up a contact list for a musician, who is about to release
her first CD.
She would like a contact list that can track the people she meets, who
will be in various categories -- fans,...
|
by: Robert J. Bonn |
last post by:
I am setting up a contact list for a musician, who is about to release
her first CD.
She would like a contact list that can track all the people she meets,
who will be in various categories --...
|
by: =?Utf-8?B?ZGIgY2hhbGxlbmdlZA==?= |
last post by:
I am realy challenged by MSN Live. I was quite happy with my former hotmail.
The new forced-upon-me version has caused me nothing but headaches and lots
of work. It consumes huge amounts of my time...
|
by: JayaseelanVaiyapuri |
last post by:
Hi,
I would like to add a menu item in Contact List menu of PocketPC using c#.
in Contact list menu contains Edit, Send Contact, copy contact etc..
Now i want to add a new menu item like...
|
by: tokcy |
last post by:
HI every one,
i am using tooltip on click of link and i want like when that tooltip open then background window would be blure().
can anyone help me...
|
by: swethak |
last post by:
hi,
i have to get the gmail contact list using jsp code. For that purpose i have to use the Google data Api
<%@ page import="com.xdatasystem.contactsimporter.*" %>
<%
// automatically...
|
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...
|
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
|
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...
|
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...
|
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,...
|
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: 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,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |