-
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

Dell PowerEdge R620 2x Xeon E5-2630 v2 3.1GHz 2.5" 4-BAY 32GB RAM No OS 2x 495w
$174.95

Dell EMC PowerEdge R440 Xeon silver 4215 2.5GHz 16 GB ram 2x 550W PSU No HDD
$275.00

Broadcom 9600-24i Tri-Mode RAID Controller 4.0 NVMe SAS SATA NEW 05-50111-01003
$639.69

Microsoft Windows Server 2022 Standard 64-bit License & DVD 16 Core US Shipping
$34.99

Supermicro 1027GR-TSF 1U Rackmount Server 2x Xeon 2.3GHz 128GB DDR3
$219.99

Dell Poweredge R720 8SFF 2.5" x Xeon E5-2680 v2 2.8GHz 20-Cores 128gb 4x Trays
$349.99

Dell Poweredge R720 8SFF 2.5" 2x Xeon E5-2680 v2 2.8GHz 20-Cores 64gb 4x Trays
$259.99

Dell PowerEdge C4130 1U AI GPU Server | 2x E5-2680 v3 | 32gb Ram | 2x 1600W
$409.99
![WINDOWS SERVER 2025 [REMOTE DESKTOP SERVICES] 50 USER RDS CAL SEALED picture](/store/img/g/Fn8AAOSwCcpn9N3z/s-l225/WINDOWS-SERVER-2025-REMOTE-DESKTOP-SERVICES-50-USE.jpg)
WINDOWS SERVER 2025 [REMOTE DESKTOP SERVICES] 50 USER RDS CAL SEALED
$119.18

Supermicro 721-2 Mini Tower Black Computer Server NO Hdd
$375.00