+ 1
If I created string function can i put int parameters in it ?
Functions
11 ответов
+ 1
Yes u can. If in java u can use "Integer.parseInt" but u still need Enter the integer on it. If not it will return to NumberFormatException
+ 1
yes, i think it will work, because u return string parameters on "return "My number is:"<<var<<endl;" and integer just parentheses.
+ 1
or try this
#include <string>
std::string s = std::to_string(42);
source: https://stackoverflow.com/questions/5590381/easiest-way-to-convert-int-to-string-in-c
0
Dwi Noviantp Nugroho In c++ ?
0
Ace
#include <iostream>
using namespace std;
string function(int var){
return "My number is:"<<var<<endl;
}
int main(){
cout <<function(5);
return 0;
}
I put int var inside the parameters of the string function and I wrote it's value down. Will this work ?
0
What do you mean by parentheses ?
0
What std::to_string does ?
0
Does std::+ to_string converts int to string ?