Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

how to insert variable into string c++

#include <iostream>

using namespace std;

int main()
{

    //variables
    string name = "Jacob";
    int age = 21;

    //code with variable insertions
    cout << name << " was a cool dude." << endl;
    cout << "So it's weird that no one really liked " << name << "." << endl;
    cout << name << " was " << age << " years old." << endl;

    return 0;
}
 
PREVIOUS NEXT
Tagged: #insert #variable #string
ADD COMMENT
Topic
Name
3+4 =