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
  •  


Dell Poweredge R720 8SFF 2.5

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

$349.99



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

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

$275.00



Dell EMC 15-Bay 3.5

Dell EMC 15-Bay 3.5" SAS Disk Array Enclosure 12Gbps Dual LCC - 2x Power Supply

$249.00



Dell Poweredge R720 8SFF 2.5

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

$259.99



Dell PowerEdge R620 2x Xeon E5-2630 v2 3.1GHz 2.5

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

$174.95



Dell Poweredge R630 2x Xeon E5-2680 v4 2.4ghz 28-Core | 32GB | HBA330 | 2x 1100w picture

Dell Poweredge R630 2x Xeon E5-2680 v4 2.4ghz 28-Core | 32GB | HBA330 | 2x 1100w

$359.99



Dell PowerEdge R640  8xSFF Server Barebone 2 x Heat Sink w / 2x 1100W PSU picture

Dell PowerEdge R640 8xSFF Server Barebone 2 x Heat Sink w / 2x 1100W PSU

$315.00



Dell Poweredge T420 SFF 2x E5-2430 v2 2.5Ghz / 64gb / H710 / 8x Trays / 2x 495w picture

Dell Poweredge T420 SFF 2x E5-2430 v2 2.5Ghz / 64gb / H710 / 8x Trays / 2x 495w

$394.99



DELL R640 10SFF Server 2x Gold 6152 2.1GHz =44 Cores 64GB H730p 4xRJ45 picture

DELL R640 10SFF Server 2x Gold 6152 2.1GHz =44 Cores 64GB H730p 4xRJ45

$939.00



Dell R640 Diskless Servers 2x Gold 18-Cores 6254 3.10GHz CPU, 32gb RAM, No Raid picture

Dell R640 Diskless Servers 2x Gold 18-Cores 6254 3.10GHz CPU, 32gb RAM, No Raid

$699.00