|
From: Daniel G. <sp...@ho...> - 2001-10-22 18:06:48
|
<html><div style='background-color:'><DIV>
<P>Are you sure? I was taught to always ALWAYS do <iostream.h> . Even when they spoke about it in my course they said iostream.h<BR><BR></P></DIV>
<DIV></DIV>
<DIV></DIV>>From: "Ioannis Vranos" <NO...@YA...>
<DIV></DIV>>To: "Dev-C++" <DEV...@LI...>
<DIV></DIV>>Subject: RE: [Dev-C++] using strings
<DIV></DIV>>Date: Mon, 22 Oct 2001 14:23:17 +0200
<DIV></DIV>>
<DIV></DIV>>string.h is the C header file. ANSI C++ header files are without .h and
<DIV></DIV>>more properly written:
<DIV></DIV>>
<DIV></DIV>>#include <IOSTREAM>
<DIV></DIV>>#include <IOMANIP>// For setw()
<DIV></DIV>>#include <FSTREAM>// For file I/O
<DIV></DIV>>#include <STRING>
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>int main()
<DIV></DIV>>{
<DIV></DIV>> using namespace std;
<DIV></DIV>>
<DIV></DIV>> string s1;
<DIV></DIV>> char pause;
<DIV></DIV>>
<DIV></DIV>> cin >> s1;
<DIV></DIV>> cout << endl << s1 << endl;
<DIV></DIV>> cout << "pause";
<DIV></DIV>> cin >> pause;
<DIV></DIV>>
<DIV></DIV>>}
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>return 0; is not needed in ANSI C++. If in main() you do not return any
<DIV></DIV>>value, 0 is automatically returned to the system.
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>Ioannis
<DIV></DIV>>
<DIV></DIV>>* Ioannis Vranos
<DIV></DIV>>* Programming pages: http://www.noicys.f2s.com
<DIV></DIV>><HTTP: www.noicys.f2s.com />
<DIV></DIV>>* Alternative URL: http://run.to/noicys
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>-----Original Message-----
<DIV></DIV>>From: dev...@li...
<DIV></DIV>>[mailto:dev...@li...] On Behalf Of Daniel
<DIV></DIV>>Anderson
<DIV></DIV>>Sent: Sunday, October 21, 2001 7:38 PM
<DIV></DIV>>To: dev...@li...
<DIV></DIV>>Subject: [Dev-C++] using strings
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>Hello,
<DIV></DIV>>A seemingly simple problem has stumped me so far. I cannot figure out
<DIV></DIV>>how to use simple strings in my programs. Do I need to add the
<DIV></DIV>><CSTRING.H> library? If so, my compiler says it can't find it- can I
<DIV></DIV>>download this somewhere? I know I can get around this problem by using
<DIV></DIV>>an array of chars, but I want to be able to use strings. I am using Dev
<DIV></DIV>>4.01 and the mingw compiler 2.95.2-1. A thousand thanks for any help.
<DIV></DIV>>
<DIV></DIV>>D
<DIV></DIV>>
<DIV></DIV>>When I try to compile this program, I can a 'string' undeclared (first
<DIV></DIV>>use this function) error.
<DIV></DIV>>// start
<DIV></DIV>>
<DIV></DIV>>#include <IOSTREAM.H>
<DIV></DIV>>#include <IOMANIP.H>// For setw()
<DIV></DIV>>#include <FSTREAM.H>// For file I/O
<DIV></DIV>>#include <STRING.H>
<DIV></DIV>>
<DIV></DIV>>using namespace std;
<DIV></DIV>>
<DIV></DIV>>int main()
<DIV></DIV>>{
<DIV></DIV>> string s1;
<DIV></DIV>> char pause;
<DIV></DIV>>
<DIV></DIV>> cin >> s1;
<DIV></DIV>> cout << endl << s1 << endl;
<DIV></DIV>> cout << "pause";
<DIV></DIV>> cin >> pause;
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>> return 0;
<DIV></DIV>>}
<DIV></DIV>>
<DIV></DIV></div><br clear=all><hr>Get your FREE download of MSN Explorer at <a href='http://go.msn.com/bql/hmtag_itl_EN.asp'>http://explorer.msn.com</a><br></html>
|