string add

if

string str = "sfsdfsd"

and i want to add like str[3]+str[4]

but it return some integer value

why? and how to fix it?
First, use == instead of = when checking to see if two values are equal. Using = will always return true. Secondly, what do you want it to return? You could try using char(str[3]+str[4])
@codeback99
It isn't clear what you want to do. If you want to append to the end of a string use str += "text" or use the append member function http://www.cplusplus.com/reference/string/string/append/
If you want to insert text in the string use the insert member function http://www.cplusplus.com/reference/string/string/insert/
If neither of these are what you want then please describe the problem better.
Last edited on
Even better, you could you post a small, complete program that illustrates your problem?

Andy

PS Using code tags, like...

1
2
3
4
5
6
7
8
#include <iostream>
using namespace std;

int main() {
    cout << "Hello nicely formatted world!\n";

    return 0;
}


How to use code tags
http://www.cplusplus.com/articles/jEywvCM9/
Topic archived. No new replies allowed.