473,396 Members | 2,108 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.

Contact List

Hunderpanzer
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:
Expand|Select|Wrap|Line Numbers
  1. if (x == "a" || x == "A"){
  2.        cout << "A list of contacts should appear" ;
  3.        }
  4.     else{
  5.          cout << "Pardon me?  Please type that again... ";
  6.          cin >> x;
  7. }
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
Jul 25 '07 #1
8 3527
ilikepython
844 Expert 512MB
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:
Expand|Select|Wrap|Line Numbers
  1. if (x == "a" || x == "A"){
  2.        cout << "A list of contacts should appear" ;
  3.        }
  4.     else{
  5.          cout << "Pardon me?  Please type that again... ";
  6.          cin >> x;
  7. }
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:
Expand|Select|Wrap|Line Numbers
  1. char x;
  2. do
  3. {
  4.     cin >> x;
  5. }
  6. while (tolower(x) != 'a' && tolower(x) != 'b' && tolower(x) != 'c');
  7. // x is either 'a', 'b', or 'c'
  8.  
Jul 25 '07 #2
gpraghuram
1,275 Expert 1GB
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:
Expand|Select|Wrap|Line Numbers
  1. if (x == "a" || x == "A"){
  2.        cout << "A list of contacts should appear" ;
  3.        }
  4.     else{
  5.          cout << "Pardon me?  Please type that again... ";
  6.          cin >> x;
  7. }
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.
Expand|Select|Wrap|Line Numbers
  1. {
  2.         string x;
  3.         cout<<"enter a value"<<endl;
  4.         cin>>x;
  5.         while(1)
  6.         {
  7.             if(x == "a" || x== "b")
  8.             {
  9.                 cout<<"done ..."<<endl;
  10.                 break;
  11.             }
  12.             else
  13.             {
  14.                 cout<<"Re-enter a value"<<endl;
  15.                 cin>>x;
  16.             }
  17.         }
  18.     }
  19.  
Raghuram
Jul 25 '07 #3
gpraghuram
1,275 Expert 1GB
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.
Expand|Select|Wrap|Line Numbers
  1. {
  2.         string x;
  3.         cout<<"enter a value"<<endl;
  4.         cin>>x;
  5.         while(1)
  6.         {
  7.             if(x == "a" || x== "b")
  8.             {
  9.                 cout<<"done ..."<<endl;
  10.                 break;
  11.             }
  12.             else
  13.             {
  14.                 cout<<"Re-enter a value"<<endl;
  15.                 cin>>x;
  16.             }
  17.         }
  18.     }
  19.  
Raghuram

I think i answered this a litle late.......
Jul 25 '07 #4
I think i answered this a litle late.......
Hehe, that's okay, I still appreciate you !



Expand|Select|Wrap|Line Numbers
  1. char x;
  2.  
  3. do
  4.  
  5. {
  6.  
  7.     cin >> x;
  8.  
  9. }
  10.  
  11. 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?
Jul 25 '07 #5
ilikepython
844 Expert 512MB
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'".
Jul 25 '07 #6
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!
Jul 25 '07 #7
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
Jul 26 '07 #8
gpraghuram
1,275 Expert 1GB
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
Jul 26 '07 #9

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

Similar topics

9
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...
3
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...
1
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...
1
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...
1
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,...
0
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 --...
0
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...
2
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...
4
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...
2
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...
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...
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
tracyyun
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...

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.