Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > #include string

#include string
Thread Tools
Fresh-Faced Recruit
Join Date: Apr 2001
Status: Offline
Reply With Quote
Apr 26, 2001, 09:45 AM
 
ack...meant to be a reply to CC header libraries. sorry

#include <string> will work. I was using it just the other day to do some C++ programming for a class. Your compiler is c++, also note there is a bug in it when doing input. If you want a console prompt for input, you must end the line if you want it to display before the console waits for input.

ie:
#include <iostream>
#include <string>
using namespace std;
// Read and display data.
int main()
{ string input;
cout << "Type a word: ";
cin >> input;
cout << "You typed: " << input << endl;
return 0;
}
needs to be changed to:
#include <iostream>
#include <string>
using namespace std;
// Read and display data.
int main()
{ string input;
cout << "Type a word: " << endl; // note the endl; here, this is the change
cin >> input;
cout << "You typed: " << input << endl;
return 0;
}

Just a little heads up on a glitch to come. Compile and run each to see specifically what I mean. Apple needs to do a little work on the c++ compiler. :-)

Ryan C.


[This message has been edited by rwc9785 (edited 04-26-2001).]
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:27 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2