// 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;

	system("PAUSE");
	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.

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.

try to use this:

char ch=' ';
int n=0; // for counting letters
for (int i=0;i<string.size();i++)
{
if (char!=string[i])
n++;
commented: I don't think so.... -1

can you put it in my code and i can just copy paste it??

commented: You've been around long enough, you should know better. -1
commented: Fail -3
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.