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
  •  


Samsung 4GB (1-Stick) PC4-17000 DDR4 2133 Desktop Memory RAM M378A5143EB1-CPB picture

Samsung 4GB (1-Stick) PC4-17000 DDR4 2133 Desktop Memory RAM M378A5143EB1-CPB

$9.99



DDR4 Laptop RAM 4GB 8GB 16GB 32GB 2400 2666 3200 Samsung Hynix picture

DDR4 Laptop RAM 4GB 8GB 16GB 32GB 2400 2666 3200 Samsung Hynix

$66.00



RAMAXEL Lenovo 32GB LPDDR5X CAMM2 7500MHz Laptop RAM | UNTESTED picture

RAMAXEL Lenovo 32GB LPDDR5X CAMM2 7500MHz Laptop RAM | UNTESTED

$445.00



Crucial CT16G4SFRA32A.M8FF 16GB DDR4-3200 SO-DIMM Laptop Ram Memory picture

Crucial CT16G4SFRA32A.M8FF 16GB DDR4-3200 SO-DIMM Laptop Ram Memory

$54.00



Crucial DDR3L 16GB 2 x 8GB 1600 MHz PC3L-12800 Laptop RAM Sodimm Memory 1.35V picture

Crucial DDR3L 16GB 2 x 8GB 1600 MHz PC3L-12800 Laptop RAM Sodimm Memory 1.35V

$41.00



Major Brand 8GB PC3L-12800 (DDR3-1600) 2Rx8 DDR3L SDRAM Desktop Memory picture

Major Brand 8GB PC3L-12800 (DDR3-1600) 2Rx8 DDR3L SDRAM Desktop Memory

$12.99



Corsair Vengance DDR4 3200 MHz Sodimm 32 Giga (2*16) CMSX 16GX4M1A3200C22 picture

Corsair Vengance DDR4 3200 MHz Sodimm 32 Giga (2*16) CMSX 16GX4M1A3200C22

$120.00



A-Tech 8GB DDR3 1600 PC3-12800 Laptop SODIMM 204-Pin Memory RAM PC3L DDR3L 1x 8G picture

A-Tech 8GB DDR3 1600 PC3-12800 Laptop SODIMM 204-Pin Memory RAM PC3L DDR3L 1x 8G

$21.68



Micron MTC40F2046S1RC48BA1 DDR5 64GB (1x64GB) 4800MHz RDIMM ECC Server Memory picture

Micron MTC40F2046S1RC48BA1 DDR5 64GB (1x64GB) 4800MHz RDIMM ECC Server Memory

$2599.99



4GB 8GB RAM Desktop Memory Modules Sticks Kit Lot - Choose 1x 2x 4x - All Tested picture

4GB 8GB RAM Desktop Memory Modules Sticks Kit Lot - Choose 1x 2x 4x - All Tested

$44.99