I'm pretty new to C++ and I'm trying to write a simple function to take user input and navigates to the site, adding the https://www.
at the beginning of the string, but I cant quite figure out how to call the link within the quotes (or otherwise) within the system function. I come from python so I'm used to being able to use an f string for something like this, and I'm not sure if there's a C++ equivalent, here's my code:
#include <fstream>
#include <iostream>
using namespace std;
void openChrome(string site){
string link = "https://www." + site;
system("open -a 'Google Chrome' //link//");
cout << link;
}
int main()
{
openChrome("apple.com");
}
the cout
correctly outputs the full site link, I tried moving the link var outside of the quotes, and that throws an error, so is there something obvious that I'm missing?
EDIT: The issue I'm having isn't with the string concatenation, rather if I try to call the link variable there, it just outputs as the literal since it's in quotes and interpreted directly by the terminal, and throws an error that says 'link' isn't a valid link