- #1
neu
- 230
- 3
Basically I've made a method to fill histograms and I need to use sprintf to define histogram titles with a wildcard (%s) that I call to be a string such as proton, antiproton etc depending on what dat I want to plot.
So anyway, here's an example of what I've done:
void PythiaMC_Analysis::fillMM_Histos(string histoID, double deltaPseudo) {
char histo1_name[100];
sprintf(histo1_name,"%s_Matched_deltaEta",histoID);
Fill(histo1,deltaPseudo);
}
Which I'd call after defining the histoID to be proton, antiproton or whatever. I've simplified the code to one plot for the sake of brevity.
SO basically I'm getting segmentation violations to do with this method, I have deduced that it occurs at the first occurance of sprintf. Am I using it incorrectly?
Any help would be much appreciated.
So anyway, here's an example of what I've done:
void PythiaMC_Analysis::fillMM_Histos(string histoID, double deltaPseudo) {
char histo1_name[100];
sprintf(histo1_name,"%s_Matched_deltaEta",histoID);
Fill(histo1,deltaPseudo);
}
Which I'd call after defining the histoID to be proton, antiproton or whatever. I've simplified the code to one plot for the sake of brevity.
SO basically I'm getting segmentation violations to do with this method, I have deduced that it occurs at the first occurance of sprintf. Am I using it incorrectly?
Any help would be much appreciated.