Search
 
SCRIPT & CODE EXAMPLE
 

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;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: find the number of digits of a given integer n . 
Cpp :: warning in range-based for loop in C++. How to resolve it in vscode? 
Cpp :: clean list widget qt 
Cpp :: C++ (gcc 8.3) sample 
Cpp :: what are manipulators in c++ 
Cpp :: different way to print string in c++ 
Cpp :: how to take continuous input in c++ until any value. Like for example(taking input until giving q) 
Cpp :: return value from a thread 
Cpp :: store binary data in buffer 
Cpp :: why does the pointer value doesn;t change when I change it in funciton 
Cpp :: spyder enviroment 
Cpp :: ex:Roblox 
Cpp :: ue4 foreach loop c++ 
Cpp :: cast unreal c++ 
Cpp :: vector of vector definaion in c++ 
Cpp :: c++ switch integer 
Cpp :: Magical Doors codechef solution in c++ 
Cpp :: c++ n in regex 
Cpp :: Chef and Races codechef solution in c++ 
Cpp :: onactorbeginoverlap c++ 
Cpp :: Call db.close() on Button_Click (QT/C++) 
Cpp :: c++ create vector of size 
Cpp :: How to get the last element of an array in C++ using std::array 
Cpp :: function prototype c++ 
Cpp :: c++ quicksort 
Cpp :: pointer to constant 
Cpp :: how to make a c++ iostream program restart when finished 
C :: calculate distance between 2 points X Y axis 
C :: sstf program in c 
C :: Numeri in ordine crescente C 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =