Results 1 to 3 of 3

Thread: simple c++ compile problem

  1. #1
    Senior Member registered user
    Join Date
    Nov 2003
    Posts
    203

    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?

  2. #2
    Member registered user
    Join Date
    Jun 2004
    Posts
    83
    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.

  3. #3
    Senior Member registered user
    Join Date
    Nov 2003
    Posts
    203
    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

  1. ftp hang - has to be simple problem...
    By thorby in forum Networking
    Replies: 3
    Last Post: 02-08-2005, 09:44 PM
  2. Simple but impossible problem:ppponATM,winmodem and Red Hat
    By Gianluca Impei in forum Networking
    Replies: 1
    Last Post: 11-03-2004, 05:31 AM
  3. Kernel compile problem
    By Worm in forum General Support
    Replies: 0
    Last Post: 02-01-2004, 07:42 PM
  4. Kernel compile problem - first Knoppix kernel compile
    By Nigel_Tufnel in forum Hdd Install / Debian / Apt
    Replies: 2
    Last Post: 10-20-2003, 01:09 PM
  5. compile 2.4.20-xfs problem :help
    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
  •  


IBM System X3850-X5 Server w/4x Intel  Xeon E7-4870 CPU , 512 GB DDR3 RAM,NO HDD picture

IBM System X3850-X5 Server w/4x Intel Xeon E7-4870 CPU , 512 GB DDR3 RAM,NO HDD

$1299.99



IBM QRadar xx29 2x Xeon E5-2650v4 2x 900W PSU M5120 12x 3.5

IBM QRadar xx29 2x Xeon E5-2650v4 2x 900W PSU M5120 12x 3.5" Bay Server No RAM

$149.99



IBM ADP Server Type 7870 AC1 NO HDD | 128GB RAM PC3L | 2 x Xeon  E5620 picture

IBM ADP Server Type 7870 AC1 NO HDD | 128GB RAM PC3L | 2 x Xeon E5620

$199.99



Unused IBM 09P0037 MAINBOARD For  RS/6000 7044-170 P-Series picture

Unused IBM 09P0037 MAINBOARD For RS/6000 7044-170 P-Series

$375.00



IBM SYSTEM X3500 M3 SERVER 7380AC1 TOWER Server XEON E5620 8GB RAID SEE NOTES picture

IBM SYSTEM X3500 M3 SERVER 7380AC1 TOWER Server XEON E5620 8GB RAID SEE NOTES

$108.92



IBM 4262 SYSTEM x3200 Tower - HDD Wiped, NO OS picture

IBM 4262 SYSTEM x3200 Tower - HDD Wiped, NO OS

$80.00



IBM 02YC027 Seagate ST2400MM0129 2.4TB 10K SAS 12Gb/s 2.5

IBM 02YC027 Seagate ST2400MM0129 2.4TB 10K SAS 12Gb/s 2.5" Server Hard Drive

$200.00



IBM X3650 M5 5462-AC1,2 X E5-2640V3 2.6GHZ 8C, 16 GB, DUAL 750W, 2 X 1TB SERVER picture

IBM X3650 M5 5462-AC1,2 X E5-2640V3 2.6GHZ 8C, 16 GB, DUAL 750W, 2 X 1TB SERVER

$349.99



Lot of 2 IBM blade center Type H chassis 8852 picture

Lot of 2 IBM blade center Type H chassis 8852

$559.00



IBM X3650 M4 Server System Board 00MX553 00AM209 00Y8499 00Y8457 00D2888 00W2671 picture

IBM X3650 M4 Server System Board 00MX553 00AM209 00Y8499 00Y8457 00D2888 00W2671

$230.00