I want to print out the letter B, instead I get a blank line. Any tips would be great

#include <iostream>
using namespace std;
void add(string n);

int main()
{
	string B;
	add(B);
	
}

void add(string n)
{	
	if(n.length() <= 1)
	{
		cout<<n[0]<<endl;
	}
	

}

Recommended Answers

All 3 Replies

you are not actualy defining string B. to define it to be be you could do this

string B = "B";
string B = "B";

Thanks

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.