Can not plot graph?

Can you help me? I write code in VSCode and build project with Cmake. If i put function int main(), graph can not plot. And in different case, i ignore function int main(), it works normally.

#include "TF1.h"

int main()
{
    TF1 f1("f1","sin(x)/x",0,10); // định nghĩa hàm f1 trong class TF1

    f1.SetLineColor(kCyan);    // màu của đường
    f1.SetTitle("Vo Tai Dai");    // tên của đồ thị
    f1.SetLineWidth(4);   // độ rộng của đường
    

    f1.GetXaxis()->SetTitle("x thoi");  //tên của trục x
    //f1.GetXaxis()->SetColor("24");

    f1.GetYaxis()->SetTitle("y day");  // tên của trục y

    f1.Draw(); // ve do thi f1. Ở đây dùng dấu chấm, ko dùng mũi tên được,
    
}

Please read tips for efficient and successful posting and posting code

ROOT Version: 6.18.04
Platform: Ubuntu 18.04
Compiler: Not Provided


You make your own compiled program I guess ?
You need a TApplication in that case.

You can also execute directly you macro in ROOT and you weill get the result:

File my_macro.C:

{
    TF1 f1("f1","sin(x)/x",0,10); // định nghĩa hàm f1 trong class TF1

    f1.SetLineColor(kCyan);    // màu của đường
    f1.SetTitle("Vo Tai Dai");    // tên của đồ thị
    f1.SetLineWidth(4);   // độ rộng của đường


    f1.GetXaxis()->SetTitle("x thoi");  //tên của trục x
    //f1.GetXaxis()->SetColor("24");

    f1.GetYaxis()->SetTitle("y day");  // tên của trục y

    f1.Draw(); // ve do thi f1. Ở đây dùng dấu chấm, ko dùng mũi tên được,
}

to execute it:

% root my_macro.C
   ------------------------------------------------------------------
  | Welcome to ROOT 6.21/01                        https://root.cern |
  | (c) 1995-2019, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for macosx64 on Feb 21 2020, 07:55:31                      |
  | From heads/master@v6-19-01-3031-g36ae51fa83                      |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'       |
   ------------------------------------------------------------------

root [0] 
Processing my_macro.C...
Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1
root [1] 

Result:

Thank you for your advice. It well done.