• 0
Sign in to follow this  
canudos

Entradas De Char

Question

Senhores,

nesse exemplo de entradas com tipo char qual a finalidade de se usar a linha do

cin>>ws; antes do cin.getline(). No programa exemplo que eu vi (abaixo) usando isto ws não tinha sido nem declarado?

#include <iostream>

using namespace std;

int main()

{

char FirstName [20], LastName [20];

char Address [40];

char JobPerformed [80];

cout << "Welcome to College Park Auto-Parts\n";

cout << "Enter the following information about the customer's.\n";

cout << "First Name: ";

cin >> ws;

cin.getline(FirstName, 20);

cout << "Last Name: ";

cin >> ws;

cin.getline(LastName, 20);

cout << "Address: ";

cin >> ws;

cin.getline(Address, 40);

cout << "Describe the job performed on the customer's car in 100 words or less:\n";

cin >> ws;

cin.getline(JobPerformed, 80);

cout << "\nCPAP Invoice # 1202";

cout << "\nCustomer Name: " << FirstName << " " << LastName;

cout << "\nAddress: " << Address;

cout << "\nJob Performed: " << JobPerformed;

cout << "\n\n";

return 0;

}

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this