Vector of strings

Hi I am working with c++ and esp32.
I am reading a text file from memory in this format

-----BEGIN CERTIFICATE-----\n
MIIDWTCCAkGgAwIBAgIUaS7WxW0w7Au+r/BhRnlG648Lj4wwDQYJKoZIhvcNAQEL\n
BQAwTTFLMEkGA1UECwxCQW1hem9uIFdlYiBTZXJ2aWNlcyBPPUFtYXpvbi5jb20g\n
SW5jLiBMPVNlYXR0bGUgU1Q9V2FzaGluZ3RvbiBDPVVTMB4XDTIyMTAyNzEwMTcw\n
OFoXDTQ5MTIzMTIzNTk1OVowHjEcMBoGA1UEAwwTQVdTIElvVCBDZXJ0aWZpY2F0\n
ZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANyMrNYnN+CdHmlJK/qt\n
FFyEeUeeShzVjeAATYT6QO2rmlMMqheMsgYpwZTm7jK67RazCV/p77Nk8sFbSo3l\n
sj+9/yV4pTBYltLLDs2Z4eKMAe5hrY8GDUBC1VVuy1M4pMsDb+q4ZeLdWBTD/m8h\n
cmoJXt+wQPmSdJAPf+nTYM3Uww4MEuuHclg3qijHxRp+jHK47bTzZzRMd2D5mx39\n
jE9089CiISaGaAzUohn1rj2E5BLOhrGkg1b6+GWwlp2g+ThZP9Xe5rRdgqALcCK3\n
OUScSmH4DzqNEQr8bu+qVFlkdvlGKH8OgdQCN3enkXI1izubtignwTZD2kXKuZAx\n
posCAwEAAaNgMF4wHwYDVR0jBBgwFoAUKqo8WHfhOgSPtEQAPRA7GEM6N7owHQYD\n
VR0OBBYEFLGautA6QiY4dKrX2+bbIyYDwHySMAwGA1UdEwEB/wQCMAAwDgYDVR0P\n
AQH/BAQDAgeAMA0GCSqGSIb3DQEBCwUAA4IBAQBQuVDxKZUwGLy31tIfu+bLKRX/\n
HHDowHtTg1vx6pnlNzYqh/0jjRVHBfSXS0iNmPLXoj3uaTKp58Q1xXj6XUIzTEqv\n
ihccEa/neOv7u70u58fMDkl/BEdckOyJXoWHvL8OqMQK2spdWWpPwlCGkSzFyjOl\n
Sb2nmJ2gK+WiJNbKxHipL1FFEn4UzuL5zPqx6hG4TtKXcPxfz6n7MriBp0sJTspt\n
lCcGpBEjgWpemFxf9ztF14Gm/obvmjalk/zGXn7BwofgQD+138k7qZmq/0wRa34v\n
lGp6kQh58WDetdlBxqx3ZD212BL8Kia5FU2PbNfv5LIABJsx4aRuYApJSGKs\n
-----END CERTIFICATE-----\n

I have done the following code to parse it

  vector<String> v;
  while (file.available())
  {
    v.push_back(file.readStringUntil('\n'));
  }
  file.close();

I have saved the indexes of the file content that i want…

How can I create a new String variable that concatenates v[1] + [2] + . .but in different lines for obtaing something like this

String CERT_TEST = "-----BEGIN RSA PRIVATE KEY-----\n"
                   "MIIEpQIBAAKCAQEA3Iys1ic34J0eaUkr+q0UXIR5R55KHNWN4ABNhPpA7auaUwyq\n"
                   "F4yyBinBlObuMrrtFrMJX+nvs2TywVtKjeWyP73/JXilMFiW0ssOzZnh4owB7mGt\n"
                   "jwYNQELVVW7LUzikywNv6rhl4t1YFMP+byFyagle37BA+ZJ0kA9/6dNgzdTDDgwS\n"
                   "64dyWDeqKMfFGn6McrjttPNnNEx3YPmbHf2MT3Tz0KIhJoZoDNSiGfWuPYTkEs6G\n"
                   "saSDVvr4ZbCWnaD5OFk/1d7mtF2CoAtwIrc5RJxKYfgPOo0RCvxu76pUWWR2+UYo\n"
                   "fw6B1AI3d6eRcjWLO5u2KCfBNkPaRcq5kDGmiwIDAQABAoIBAHemEbX0fMnsMy1n\n"
                   "Nua9swgmDi2eYBKYgGl/gI6dvU+zAvv/KN+xwnq5eH2xcpQu+KSR6IoSPaoTH+dq\n"
                   "AV5NuJAAIUVQ2D0MMnaVFqjPzM28queKMkAfRl0QZO/+NWwmlLBWYwbxlsSm1Dwf\n"
                   "wA7GFG4WO1QbKIS8wWPOJNTTifbfbazP7mpEOrc02i9vidRLFszcIKXU4N7OC/NI\n"
                   "1yYKdgaZQX9eAiFLmIPbgSm3R1diKLr6SboRH2lrnRIH6tyooieEq9VmaExin69t\n"
                   "hRC5oCpz1yXEezYmyvkJDN9Snvj5ARFw8x1mgI2AZWvX9H/imHI4aw5228YKhhGQ\n"
                   "Wjzy29ECgYEA/os7Cxs9Txp2GHIKpbeg9witADiVu8MVcAWvVXrdLZJjAB5IBpxF\n"
                   "5M5KKJhS5xbnN8JHCZCqZUqBuEzggGSaDJ0dun0gzXSPVVJCQviiqw368Rf5aDGc\n"
                   "NDHp8W5J+cGuCRNV7H+pW+paxbNRPgpMcClk779mvR2pvAdzzMfwF6cCgYEA3c+p\n"
                   "P0TfWZQxG0COBf/EqaXCYx/14RntFyiuPPKBalor+SK5QJO+dkJFQgMQxtf6SGFi\n"
                   "kyxyvaWhoE9iVUsafST39TIh+8tTkcqD8vSMVWNQvKf9ha2yzWIFpUNI1eTMooAg\n"
                   "NphKE0OM5bvF+K7edhd2xtIJn0yzjIItifhcVn0CgYEA4yttOV9JGyTZir2UpQs6\n"
                   "G95hT5Ywg876feyE63vokzhXJI7h5wxnEGnPI2W2b0kwd8HqVi4G9LlHBi2OGugt\n"
                   "194M3xe3Q8Wn+hSc0FpICvNCJxMnYocMCkUVrYOpf74LzUu1Xokco8yG0HRVqFHW\n"
                   "oC9BRvqB/XvQtN/NyFAUBXcCgYEAnM7gzIypBVABg02Y2d7eLjyz9pWyoqdMeHHW\n"
                   "89lQ6lnC+oa0xlVscXgaNDeslZY8Jw1JvdfPagj9ATL9xmSo3k3TSbFeWv58HvY3\n"
                   "X/vIddkXS7fLP8TzQcUJTrMJe8Ubccn4fAAfZgz8P7EGnO8q7/tYiegUy1xTFoM1\n"
                   "JHPC+5UCgYEAp3d6hOl1MMSLqVajk8AS8o6AHJbVY4LYg5dXWP6AEl8xvnfXnhW0\n"
                   "H0rMJmHZcW4+2gXIMd5/G9mJnaz8jqtzcyyH4ysBJR+DepGeISZkCjuAUNwAd8UG\n"
                   "+Ttzy6ZXy6OKCv6lJW0U9S+wub1hbEUKKH4tRx1c6BoI8CmwqnfeX4M=\n"
                   "-----END RSA PRIVATE KEY-----\n";

Thanks a lot

I don’t understand what you’re trying to do, and what you have a problem with.

U don’t know how to concatenate strings? What do you mean “but in different lines”?

Hi @dvdnwk
Thanks for your help.

I have a long txt file in spiff memory of esp32.
I want to create a new string variable equal to the last that I have posted.
Which is the easy and fast way to read the whole txt file and obtain a string variable exactly equal to the one that I have posted.
I have tried with vector string but then each element of the vector it is a line and i don’t know how to create a new string starting from it

maybe don’t make a vector at all.

just concatenate to a String var while you’re reading the file.

u know how to make a String and how to concatenate Strings in general? u read the docs i’ve posted?

@dvdnwk Yes and then I have in the string all the txt file.
Then I have to use .substring to obtain just what i want?

 String result;
  while (file.available())
  {
    result.concat(file.readStringUntil('\n'));
  }

Great, that’s what you wanted, right?

Well, I guess you know what you need – is substring best for that, IDK.

Great, that’s what you wanted, right?

No i just want a part of the txt file … the part that i want it is the final string that I have posted.

I guess that with substring I should get exaclty the same