Ok I figured everthing out except: 1) when it asks for my input it asks like this Enter first name: Enter last name: Enter amount:-it puts it all on the same line. Also when I run it it puts Sept. on the in the right spot but it puts 30, 2007 in the pay to the order slot. Any ideas?

#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;

string todaysDate;
string firstName;
string lastName;
double amount;

void enterData();
void printCheck();


int _tmain(int argc, _TCHAR* argv[])

{
	enterData();
	printCheck();

	return 0;
}

void enterData()
{


    cout << "Enter today's date: ";
	cin  >> todaysDate;
	cout << "Enter the first name: ";
	cin  >> firstName;
	cout << "Enter the last name: ";
	cin  >> lastName;
	cout << "Enter the amount: ";
	cin  >> amount;

	cout << endl << endl;

	
}

void printCheck()
{
    cout << "Zzyz Corp                                      Date:     "<< todaysDate <<endl;
	cout << "1164 Sunrise Avenue                                        "<<endl;
	cout << "Kalispell, Montana\n                                         "<<endl;

	cout << "Pay to the order of:" << firstName << lastName <<      "$" << amount << endl;
	
    	

	cout << "UnderSecurity Bank                                         "<<endl;
	cout << "Missoula, MT                                               "<<endl;
	cout << "                                                ____________________"<<endl;
	cout << "                                                Authorized Signature";

	cout << endl << endl;
	
}

Recommended Answers

All 2 Replies

It's because cin >> leaves junk in the input buffer when the command is finished. Use getline() instead, but you will have to remove the trailing '\n' that's in the string you read, which is an easier problem to deal with, IMAO.

Not content with posting the same thread TWICE on cprogramming.com, it's here as well.

Breath in
Breath out
Relax.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.