|
From: Ioannis V. <no...@ya...> - 2001-10-22 11:21:38
|
string.h is the C header file. ANSI C++ header files are without .h and
more properly written:
=20
#include <iostream>
#include <iomanip> // For setw()
#include <fstream> // For file I/O
#include <string>
=20
=20
int main()
{=20
using namespace std;
=20
string s1;
char pause;
=20
cin >> s1;
cout << endl << s1 << endl;
cout << "pause";
cin >> pause;
}
=20
=20
return 0; is not needed in ANSI C++. If in main() you do not return any
value, 0 is automatically returned to the system.
=20
=20
Ioannis
=20
* Ioannis Vranos
* Programming pages: http://www.noicys.f2s.com
<http://www.noicys.f2s.com/>=20
* Alternative URL: http://run.to/noicys
=20
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...] On Behalf Of Daniel
Anderson
Sent: Sunday, October 21, 2001 7:38 PM
To: dev...@li...
Subject: [Dev-C++] using strings
Hello,
A seemingly simple problem has stumped me so far. I cannot figure out
how to use simple strings in my programs. Do I need to add the
<cstring.h> library? If so, my compiler says it can't find it- can I
download this somewhere? I know I can get around this problem by using
an array of chars, but I want to be able to use strings. I am using Dev
4.01 and the mingw compiler 2.95.2-1. A thousand thanks for any help.
=20
D
=20
When I try to compile this program, I can a 'string' undeclared (first
use this function) error.
// start
=20
#include <iostream.h>
#include <iomanip.h> // For setw()
#include <fstream.h> // For file I/O
#include <string.h>
using namespace std;
=20
int main()
{=20
string s1;
char pause;
=20
cin >> s1;
cout << endl << s1 << endl;
cout << "pause";
cin >> pause;
=20
return 0;
}
|