mardi 24 mars 2020

I have used same method for string concatenation but but in the first showing error and the second one is showing the result

This code is showing error.

#include <bits/stdc++.h>

using namespace std;

int main() {
    string s;
    s="b"+"k"+"4";
    cout<<s<<endl;
    return 0; 
}

This code is working properly.

#include <bits/stdc++.h>

using namespace std;

int main() {
    string s;
    string s1 = "a";
    s=s1+"b"+"k"+"4";
    cout<<s<<endl;
    return 0; 
}

I don't know why this is happening, in both the cases i am using strings?

Aucun commentaire:

Enregistrer un commentaire