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 > Project Builder and C++

Project Builder and C++
Thread Tools
JH
Junior Member
Join Date: Apr 2001
Location: UK
Status: Offline
Reply With Quote
Jun 29, 2001, 09:03 AM
 
Are there known problems with C++ and Project Builder?
I'm trying to teach myself some programming by reading the tutorials on www.cplusplus.com and have hit a snag with the cin.getline() function,e.g
the following program:

// cin with strings
#include <iostream.h>

int main ()
{
char mybuffer [100];
cout << "What's your name? ";
cin.getline (mybuffer,100);
cout << "Hello " << mybuffer << ".\n";
cout << "Which is your favourite team? ";
cin.getline (mybuffer,100);
cout << "I like " << mybuffer << " too.\n";
return 0;
}

When pasted into a C++ file, saved with a .cpp extension and compiled using c++ .... in the terminal window produces an application which does not work as it is supposed to.

For some reason it wants the cin completed before it does the cout prompt for it... , which makes it a little confusing.
Any ideas as to what might be wrong?
Cheers
Jeff
     
SuperCed
Fresh-Faced Recruit
Join Date: Jun 2001
Location: France
Status: Offline
Reply With Quote
Jun 29, 2001, 11:56 AM
 
Try to compile this with the terminal using cc command

cc mySource -o myProgramme

and after, you just have to type ./myProgramme
     
Angus_D
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Jun 29, 2001, 02:04 PM
 
This was discussed in detail some time ago, it appears to be a bug in apple's std c++ libs, but then nobody ever uses cin/cout so I don't think it's got a very high priority. Search the archives if you like.
     
JH  (op)
Junior Member
Join Date: Apr 2001
Location: UK
Status: Offline
Reply With Quote
Jun 29, 2001, 06:08 PM
 
Someone over at the Apple discussion page has suggested I replace the libraries with ones from STLport,
I've downloaded the folder but don't know what to do with them next?
Anybody got any suggestions?
Jeff
     
   
 
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
Top
Privacy Policy
All times are GMT -4. The time now is 03:23 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,