#include <iostream>
#include<string>

using namespace std;

int main()
{
	string str1="Amusement Park";
	string str2="going to";
	string str3="the";
	string str;

	cout<<str2+''+str3+''+str1<<endl;
	cout<<str1.length()<<endl;
	cout<<str1.find('p')<<endl;
	cout<<str1.subtr(1,5)<<endl;
	str="ABCDEFGHIJK";
	cout<<str<<endl;
	cout<<str<<endl;
	cout<<str.length()<<endl;

	str[0]='a';
	str[2]='d';

	cout<<str<<endl;

 	return 0;
}

Recommended Answers

All 6 Replies

This

cout<<str2+''+str3+''+str1<<endl;

should be this

cout<<str2+' '+str3+' '+str1<<endl;

And this

cout<<str1.subtr(1,5)<<endl;

Should be this

cout<<str1.substr(1,5)<<endl;

1. string is not defined as a variable in C++. Use char* or char[50] instead.
2. str="ABCDEFGHIJK"; is erroneous. Use strcpy() or the like instead.

Thanks...

1. Next time use code tag with the language specifier:
[code=cplusplus] source

[/code]
2. Double apostrophes (empty character constant) is not a valid construct in C++ (have you ever seen the compiler diagnostic messages? ):

cout<<str2+''+str3+''+str1<<endl;

Use ' ' for the space character.

1. string is not defined as a variable in C++. Use char* or char[50] instead.
2. str="ABCDEFGHIJK"; is erroneous. Use strcpy() or the like instead.

Thanks...

??? What's a nonsense?

thankyou guyz for giving me such a fast response....

I was just so hungry. I'm sorry...
Peace...
(^_^)...

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.