0

I want to create a variable and then use it later in my C++ code (for example, I want to get the latest created folder), but have no success so far. Here is a sample code.

$ export aaaa=$(ls)
$ echo $aaaa
main.C
$ g++ main.C
$ ./a.out 
Test Env Variables
sh: 1: export: main.C: bad variable name

$ ccat main.C 
#include <iostream>
#include <stdlib.h>
using namespace std;

int main()
{
    cout<< "Test Env Variables" << endl;
    system("export DIRS=$(ls)");
    system("echo $DIRS");
}
$
Daniel
  • 2,576
  • 7
  • 37
  • 51

0 Answers0