Skip to content

Instantly share code, notes, and snippets.

@Jack2
Created November 10, 2012 02:54
Show Gist options
  • Save Jack2/4049662 to your computer and use it in GitHub Desktop.
Save Jack2/4049662 to your computer and use it in GitHub Desktop.
[C++]float_example (+cin.getline)
#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
char buffer[100];
float price;
int quantity;
cout << "단가 : ";
cin.getline(buffer,100);
price = atof(buffer);
cout << "수량 : ";
cin.getline(buffer,100) ;
quantity = atoi(buffer);
cout << "가격 : " << price*quantity << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment