-
Senior Member
registered user
simple c++ compile problem
Howdy all:
I tried to compile this very simple c++ program using gcc and/or g++.
#include <iostream> // cout, cin
main()
{
char buf[255];
cout << "Please enter a string ==> "; // O/P to STDOUT (screen).
cin >> buf; // I/P from STDIN (keyboard).
cout << "Entered string is " << buf << endl;
}
I get an error saying that cin and cout are not defined. I've tried this on both knoppix 3.3 and knoppix 3.7.
Any ideas?
-
You're using functions (cout, cin) from the standard library but you haven't told the compiler. Add the line "using namespace std;" after your include line. Or preface all your cout/cin/endl etc with std::. This is a basic C++ question, nothing to do with Knoppix etc. You code wouldn't compile on any standard compiler.
-
Senior Member
registered user
Thanks for the info, markb, I'll give your suggestion a try. Even though it wouldn't compile on any standard compiler, I forgot to mention, it compiled and ran just fine with both gcc and g++ on a Debian Woody installation.
Similar Threads
-
By thorby in forum Networking
Replies: 3
Last Post: 02-08-2005, 09:44 PM
-
By Gianluca Impei in forum Networking
Replies: 1
Last Post: 11-03-2004, 05:31 AM
-
By Worm in forum General Support
Replies: 0
Last Post: 02-01-2004, 07:42 PM
-
By Nigel_Tufnel in forum Hdd Install / Debian / Apt
Replies: 2
Last Post: 10-20-2003, 01:09 PM
-
By wangji in forum General Support
Replies: 1
Last Post: 09-19-2003, 05:11 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules

(2) Seagate SAS Hard Drive Exos 7E8 3TB 7200RPM 128MB 12Gb/s 3.5 ST3000NM0035
$49.99

Seagate BarraCuda ST3000DM008 3TB Internal SATA 6Gb 3.5" Hard Drive 7200RPM 64MB
$91.99

Dell EMC WD-HITACHI H5H72101CLAR10T0 10TB 7.2K SAS 12Gb/s SED 3.5in A POH 0-50k
$189.99

WD Ultrastar DC HC530 14TB SATA 6G 3.5" 7200RPM Enterprise HDD - WUH721414ALE604
$329.99

Seagate ST500DM009 BarraCuda 500 GB 3.5" SATA III Desktop Hard Drive
$14.99

Toshiba MG04ACA400 4TB 3.5-inch SATA 6 Gb/s 7,200 RPM Internal Hard Drive
$49.99

Toshiba 14TB MG07 MG07ACA14TEY 7.2K RPM SATA 6Gb/s 512e 3.5" Enterprise HDD
$299.00

Seagate ST28000NM001C 28TB 256MB 7200RPM 3.5" SATA 6.0Gb/s Enterprise Hard Drive
$669.99

Seagate 6TB HDD ST6000NM0034 7.2K 3.5" SAS 12Gb/s (NOT FOR PC - FOR SERVER ONLY)
$87.00

HDD 3.5" SATA Hard Drive with Windows 10/Win 11 64x Installed Legacy
$35.00