how to add number to the end of the string in c++? [closed] - c++

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I did various implementations but they take a long time
Can anyone give us the best implementation?
For example, add a ten-digit number to the end of a string
I did not find a good answer on the Internet

#include <iostream>
std::string a="string";
long n=1703705707;
a.append(std::to_string(n)); //becomes "string1703705707"

Related

Clang-Tidy: check number of lines in a function [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Can you please help me with how to check CPP files in a project for functions exceeding 'n' number of lines using Clang-Tidy?
You can use the readability-function-size check and set the LineThreshold parameter to your n value.

How to store an int from a string [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Hello I am using c++ for this assignment.
If I have a string such as "P10" and I want to store the number 10 into an integer disregarding the P, how would I do that?
Assuming you only want to remove the first character from your string then
#include <string>
std::string str = "P10";
int i = std::stoi(str.substr(1));

CPP intresting thing with conditionsl statement [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
if(cout<<"h"){}
this gives me an output
h
Any idea why, I have tried many variations of it and it still works.
That's because the if statement needs to evaluate the condition you give into it, plus, streams are implicitly convertible to bool.

Remove hastag/pound/octothorpe from string in R [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have a string which has a hastag/pound/octothorpe in it, and want it removed using a regex expression.
e.g.
iii <- '#lkdjljf, lkdflsdkf'
i would like a gsub(regex_bit_here,'',iii)
to remove the hastag/pound/octothorpe
Thanks
I have triedgsub("^#",'',iii), and it works

Turning a string that contains a equation into an integer [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I would like to be able to convert a string such as "(5+6)*6" and get the resulting integer from that equation. It is important that it starts out as a string.
You can use library fastmathparser for c++.
In link is example how use this library.
If you really want write alone this parser, I recomended use Shunting-yard algorithm