// This program is supposed to figure out how much does a custom banner cost by figuring out the price for each letter and outputting it's total to the screen.

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

int main()
	double cost = 3.45, total;
	string banner;
	cout << "Enter Your Banner Name (Do not use spaces)" << endl;
	cout << endl;
	getline(cin, banner); //User inputs their custom banner name
	cout << endl;

	// Outputs how many letters are in the banner
	for (int i = 0; i < banner.size(); ++i) 
		cout << "This sentence has " << i << " letters in it." << endl;
	cout << endl;

	cout << "How much does each letter Cost? $";
	cin >> cost;
	cout << endl;

	// Calculates the total cost of your made banner
	total = cost * (double)banner.size(); 
	cout << "Your total cost is: $ " << total << endl;
	cout << endl;

	return 0;

How do I get rid of the 4018 warning and How can i make the program count how many letters are in the banner and not count spaces as letters too. I appreciate the help guys =). No homo.

Edited by Zvjezdan23: cin &gt;&gt; banner is bad

6 Years
Discussion Span
Last Post by Nick Evan
Featured Replies

What's "the 4018 warning"? I'm afraid there aren't many of us that know what each error/warning number means.

Read the input as a string. Then, step through the string like an array of char. While stepping through the string, determine what kind of character it is and respond accordingly. For the rest of the answer, study the <cctype> header perhaps the answer will come to you.

Edited by Fbody: n/a


try to use this:

char ch=' ';
int n=0; // for counting letters
for (int i=0;i<string.size();i++)
if (char!=string[i])

Edited by cppgangster: n/a

I don't think so....
This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.