Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > help with a basic c++ issue

Thread Tools

help with a basic c++ issue

cougar cougar is offline
Junior Member
Join Date: Feb 2008
Posts: 1
Visual Studio 6.0 C++ w/sp6

Problem possibly with how compiler reads getline. I assume getline is not reading end of line.

I prompt to enter the name of the movie. After inputting the name of the movie, I press enter. Cursor goes to next line and waits for me to press the <enter> key and then it goes on with the program. To test in a different program, I wrote a simple program to display output and in my first cout statement (exact same spot of this program with trouble) - after the semicolon, I pressed enter and it indented the next line. Normally, it'll go to the beginning of the next line but it didn't.

Here is my program. Any help would be appreciated.

// This program will calculate a theater's gross and net box office profit for 1 night.
// This program will display the movie name, child and adult tickets sold, gross and net
//profit and amount paid to distributor.

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

int main()
string movieTitle;
int a_sold, c_sold;
double a_total, c_total, gross, net, dist;
const double APRICE = 6.00, CPRICE = 3.00;

cout << "Enter the name of the movie " << endl;
getline(cin, movieTitle);
cout << "Enter the number of Adult tickets sold " << endl;
cin >> a_sold;
cout << "Enter the number of Child tickets sold " << endl;
cin >> c_sold;

a_total = APRICE * a_sold;
c_total = CPRICE * c_sold;
gross = a_total + c_total;
dist = gross * .8;
net = gross * .2;

cout << "Movie Title " << movieTitle << endl;
cout << "Adult Tickets Sold " << a_sold << endl;
cout << "Child Tickets Sold " << c_sold << endl;
cout << "Gross Box Office Profit " << gross << endl;
cout << "Amount Paid to Distributor " << dist << endl;
cout << "Net Box Office Profit " << net << endl;

return 0;

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Storage Issue (Basic Issue) Srini Java 11 06-01-2008 01:17 AM
What is the difference between Visual Basic.NET and Visual Basic 6? Jimmy Dean Computer Support 3 07-25-2005 07:05 AM
Re: Python interpreter in Basic or a Python-2-Basic translator. Python 0 05-02-2005 01:48 PM
Python interpreter in Basic or a Python-2-Basic translator. Engineer Python 6 05-01-2005 10:16 PM
Upgrading Microsoft Visual Basic 6.0 to Microsoft Visual Basic .NET Jaime MCSD 2 09-20-2003 05:16 AM