Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello Every one,
I have a problem related to string declaration in a small program I want to compile in UNIX. I have already included the and header files. For some reason the prgram is not recognizing declaration like "string filename". It is giving a message saying that string is used as a type but is not defined as a type. Below is shown part of the program, which also include other header files. I greatly appreciate your advise on the problem. Thanks.
Wond
// The Program does Simple Spectrum Subtraction
// August 15, 2003: Wond
//
#include
#include
#include // for atoi().
#include // For asprintf().
#include // for atan(), fabs() and pi.
#include // analyze many files as one.
#include // for getopt() and friends.
#include // C string utilities.
#include
#include
#include // For string streams.
#include
#include // We use the STL basic_string for filenames.
#include "TROOT.h"
#include "TFile.h"
#include "TH2.h"string analysisfilename;
string outfilename; // String for output file(s).
string rootfilename; // Name of ROOT input file.
string histogramname("hist"); // Name of TH2F* to extract from ROOT filefloat livetimefactor = 1.0;
int main(int argc, char **argv)
{
// String for input file.

This is a comment on my previous posting on string declaration. For some reason in my prvious posting, all the header file names with angle brackets are not shown. However all the string header files are included, string.h and the string, in the actual program. I appreciate your help.
Wond

What language?? C??
string is not a valid data type in C, unless you are using a special library.
Contrary to how it may sound, string.h does not define a string data type.
To use strings, you need to declare character arrays.
For example:
char analysisfilename[30];

Thanks Don,
I was using C++. I tried "using namespace std", and it worked. What you suggested also works. Thanks for the suggestion.
Wond

![]() |
unix commands
|
Clone Sco Unix Drive
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |