-
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

Fortinet FortiGate FortiWiFi 80F Network Security Firewall (FG-80F)
$83.99

Netgate SG-1100 Security Gateway Appliance pfSense Plus Firewall - Open Box
$150.00

Zero Trace Pen: All-in-one Tor Network Anonymous Drive + Cryptocurrency Wallet
$147.00

Untangle z12 NG Firewall Server Caswell CAR-3070
$329.99

Palo Alto PA-220 Next-Gen Firewall 520-000309-00J
$40.00

Sophos XG 135 Rev.2 Next-Gen Firewall | C1226*
$49.99

SOPHOS XG 135 Rev 3 Revision Network Appliance Security Firewall HDMI AC Adapter
$155.00

CloudGenix ION 2000 SD-WAN Appliance 128GB Enterprise SSD 4GB DDR3 RAM w/ PSU
$45.00

SONICWALL TZ370 NETWORK SECURITY FIREWALL APPLIANCE VPN 8 PORT GIGABIT ROUTER
$95.50

Cisco ASA 5506-X Network Security Firewall Appliance- No Adapter
$50.00