Imagine your macro file is named namefile.C, the function in your file should be also named name file… or the opposite if your function is named Example the macro file should be named Example.C … then to execute it you should do:
$ root
------------------------------------------------------------------
| Welcome to ROOT 6.19/01 https://root.cern |
| (c) 1995-2019, The ROOT Team; conception: R. Brun, F. Rademakers |
| Built for macosx64 on Sep 26 2019, 14:45:29 |
| From heads/master@v6-19-01-1381-gc7c1340fbe |
| Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
------------------------------------------------------------------
root [0] .x Ciao.C("Dati.txt","Dati.root")
Dati letti: 14
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
root [1]
where have you put the txt file? I have put it in macros folder but it continues to tell me that file Dati.txt doesn’t exist. I use Visual Studio 2019 and Windows 10
Your macro opens the txt file in the current working directory.
I put the macro and the txt file in the same folder: the folder from where you should run root.
I put them in the same folder. The folder (called macros ) in which i put programs in order to run them but it seems it doesnt see the txt, if we delete the if root tells me that it has read 0 data instead of 14.
I dont know probably this problem is linked with