473,320 Members | 2,006 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,320 software developers and data experts.

When I call a function it won't print the information to screen.

The Thankyou(); function will not print the variables fname and lname to screen.
the variables are extracted from a file.

Expand|Select|Wrap|Line Numbers
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <fstream>
  4. #include <iomanip>
  5.  
  6. using namespace std;
  7.  
  8. void thankYou();
  9. void showMenu();             
  10.  
  11. int main(int argc, char *argv[])
  12. {
  13.       const int SIZE = 60;
  14.       const int ADDRESS_SIZE =128;
  15.  
  16.       char status[SIZE];
  17.       char fname[SIZE];
  18.       char lname[SIZE];
  19.       char phoneNum[SIZE];
  20.  
  21.       char streetAdd[ADDRESS_SIZE];
  22.  
  23.       double transAmount;
  24.       char choice;
  25.       char again;
  26.       fstream people;
  27.       ofstream outFile;
  28.  
  29.         people.open ("C:\\potentials.txt");
  30.         if(!people)
  31.         {
  32.         cout <<" Error opening file.\n";
  33.         system("PAUSE");
  34.         return EXIT_FAILURE;
  35.         }
  36.         outFile.open("C:\\confirmed.txt");
  37.         if(!outFile)
  38.         {
  39.         cout <<" Error opening file confirmed.\n";
  40.         system("PAUSE");
  41.         return EXIT_FAILURE;              
  42.         }
  43.  
  44.         cout <<" Here are the Potential Customers:\n\n";
  45.  
  46.         people >> status;
  47.         people >> fname;
  48.         people >> lname;
  49.         people >> phoneNum;
  50.  
  51.         do
  52.         {                
  53.         if(!strcmp(status, "X"))
  54.         {
  55.         cout <<" "<< fname <<" "<< lname <<" "<< phoneNum 
  56.              << " Gets a 6.9% interest rate.\n";
  57.         }   
  58.         else
  59.         {
  60.         cout <<" "<< fname <<" "<< lname <<" "<< phoneNum 
  61.              << " Gets a 12.9% interest rate.\n";
  62.         } 
  63.  
  64.         showMenu();
  65.         cin >> choice;
  66.         cin.ignore();        
  67.             switch(choice)
  68.             {
  69.                case 'a':
  70.                case 'A':
  71.                {
  72.                cout <<" Ask for their Address and enter it here:\n";
  73.                cin.getline(streetAdd, ADDRESS_SIZE);
  74.                outFile << fname <<" "<< lname <<" "<< status <<" "
  75.                        << streetAdd <<" New customer" << endl;
  76.                system("cls");
  77.                thankYou();
  78.                break;
  79.                }
  80.  
  81.                case 't':
  82.                case 'T':
  83.                {
  84.                   if(!strcmp(status, "X"))
  85.                   {
  86.                   cout <<" Enter transfer amount.\n";
  87.                   cin >> transAmount;
  88.                   cin.ignore();
  89.                   cout <<" Ask for their Address and enter it here:\n";
  90.                   cin.getline(streetAdd, ADDRESS_SIZE);
  91.                   outFile << setprecision(2) << fixed;
  92.                   outFile << fname <<" "<< lname <<" "<< status 
  93.                           <<" "<< streetAdd <<" Transfer: $"<< transAmount << endl;
  94.                   system("cls");
  95.                   thankYou();
  96.                   break;
  97.                   } 
  98.                   else
  99.                   {
  100.                   cout <<" You can transfer up to $1000.00.\n";
  101.                   cout <<" Enter transfer amount: ";
  102.                   cin >> transAmount;
  103.                   cin.ignore();
  104.                   cout <<" Ask for their Address and enter it here:\n";
  105.                   cin.getline(streetAdd, ADDRESS_SIZE);
  106.                   outFile << fname <<" "<< lname <<" "<< status 
  107.                           <<" "<< streetAdd <<" Transfer: $"<< transAmount << endl;
  108.                   system("cls");
  109.                   thankYou();
  110.                   break;
  111.                   while(transAmount <= 0 || transAmount > 1000.00)
  112.                      {
  113.                      cout <<" Please enter an amount of $1000.00 "
  114.                           <<" or less.\n";
  115.                      cin >> transAmount;
  116.                      cout <<" Ask for their Address and enter it here:\n";
  117.                      cin.getline(streetAdd, ADDRESS_SIZE);
  118.                      outFile << fname <<" "<< lname <<" "<< status 
  119.                              <<" "<< streetAdd <<" Transfer: $"<< transAmount << endl;
  120.                      thankYou();
  121.                      cin.ignore();
  122.                      break;
  123.                      }            
  124.                   }            
  125.                }
  126.                case 'd':
  127.                case 'D':
  128.                {
  129.                   if(!strcmp(status, "X") == 1)
  130.                   {
  131.                   system("cls");
  132.                   cout <<" Call 1-800-ROBmeTO for special CASH back rewards.\n"
  133.                        <<" Don't miss out!\n"; 
  134.                        break;                 
  135.                   }
  136.                   else
  137.                   {
  138.                   system("cls");
  139.                   cout <<" Thank you for your time and have a nice day.\n";
  140.                   break;   
  141.                   }       
  142.                }     
  143.             }
  144.  
  145.         people >> status;
  146.         people >> fname;
  147.         people >> lname;
  148.         people >> phoneNum;
  149.  
  150.         cout <<"\n Press the enter key to get the next record.\n";
  151.  
  152.         cin.get(again);
  153.  
  154.         }while(!people.eof());
  155.         cout <<" That is all the data in the file!\n";
  156.         people.close(); 
  157.         outFile.close();
  158.  
  159.     system("PAUSE");
  160.     return EXIT_SUCCESS;
  161. }
  162.             void showMenu()
  163.             {                
  164.             cout <<" \n\t\tCredit Card Menu\n\n" 
  165.                  <<" Choose from the following menu.\n\n"
  166.                  <<" A --> If they (A)ccept the card\n"
  167.                  <<" T --> If they want to (T)ransfer a balance\n"
  168.                  <<" D --> If they (D)ecline the card\n"
  169.                  <<"\n Enter their choice\n"; 
  170.             }
  171.  
  172.         void thankYou()
  173.         { 
  174.             const int SIZE = 60;
  175.             char fname[SIZE];
  176.             char lname[SIZE];
  177.  
  178.             cout <<"\n\tCongradulations\n" << fname <<" "<< lname << endl;
  179.             cout <<" Your card will arrive by mail soon.\n";
  180.             cout <<" On behalf of RobMeBlind Credit Card Company\n";
  181.             cout <<" I would like to thank you for your order and\n";
  182.             cout <<" wish you happy shopping.\n";   
  183.         }
  184.  
Attached Files
File Type: zip teleGuide.zip (1.5 KB, 46 views)
Apr 1 '10 #1
4 1849
jkmyoung
2,057 Expert 2GB
You've declared NEW local variables in your function:
const int SIZE = 60;
char fname[SIZE];
char lname[SIZE];

You need to pass fname, lname as arguments to the function instead:
void thankYou(char[] fname, char[] lname)

and call the function
thankYou(fname, lname);
Apr 1 '10 #2
Thank you for the reply, I also converted all variables to strings. It made it much easier.
Henry
Apr 2 '10 #3
Thank you,
For someone like myself(wanting to program for a living) do you have any advise or could you point me in the direction I need to go. I was injured on the Job three years ago and must change careers. I love programming but I am unclear on the right direction.
Apr 2 '10 #4
Studlyami
464 Expert 256MB
I'm glad you got a solution here, but your next question is a better one for the software development section on this site. Programming is a broad field and you need to find what type of programming you like to do. I would say at first keep working through tutorials and try various types of programming and see what appeals to you. I would also say school would be a great decision for programming. There have been a lot of online discussions on schooling vs self learning, but personally I think both are needed. School for a good foundation and then self learning to pick up the various ins and outs of the language.
Apr 2 '10 #5

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

Similar topics

2
by: FAN | last post by:
I want to define some function in python script dynamicly and call them later, but I get some problem. I have tried the following: ################################## # code...
28
by: Sathyaish | last post by:
If fopen fails, is there a way to know why?
8
by: Galina | last post by:
Hello I have 6 dependent list boxes on my ASP page:  Faculty;  Lecturer;  Course;  Course occurrence;  Group;  Week commencing date. When faculty is selected, lists of lecturers and...
5
by: Kurt Van Campenhout | last post by:
Hi, I am trying to get/set Terminal server information in the active directory on a windows 2000 domain. Since the ADSI calls for TS don't work until W2K3, I need to do it myself. I'm fairly...
4
by: News | last post by:
Hi Everyone, The attached code creates client connections to websphere queue managers and then processes an inquiry against them. The program functions when it gets options from the command...
12
by: John Henry | last post by:
Hi list, Just to make sure I understand this. Since there is no "pointer" type in Python, I like to know how I do that. For instance, if I do: ...some_huge_list is a huge list...
8
by: Simon Willison | last post by:
Hi all, I have an API design question. I'm writing a function that can either succeed or fail. Most of the time the code calling the function won't care about the reason for the failure, but...
8
by: Alvin | last post by:
I'm making a very simple game in SDL, and I'm not asking for SDL help I hope - this looks like something C++ related, so I'll ask here. I have a class for a simple block, or tile, in the game,...
3
by: Francesco Guerrieri | last post by:
Hi, Today I've been thinking a bit about the "python internals". Inspired by this recipe: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66062 I found out a little problem which...
9
by: newbiegalore | last post by:
Hello everyone :-) , Thanks to the gentle people on this group for helping me out with previous issues. :-D This time round I am facing what I perceive as a simple problem, which I have not found...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.