Compile error

This is a discussion on Compile error within the Linux Programming forums, part of the Platform Specific Boards category; Okay, I just started using Mandrake linux 9.2. I have this program.... Code: #include <iostream.h> #include <stdio.h> int main() { ...

  1. #1
    using namespace Trooper; St0rmTroop3er's Avatar
    Join Date
    Sep 2003
    Posts
    77

    Compile error

    Okay, I just started using Mandrake linux 9.2.

    I have this program....


    Code:
    #include <iostream.h>
    #include <stdio.h>
    
    int main()
    {
    cout << "This is cpp";
    system("pause");
    return(0);
    }

    and I get this error:



    No Input File
    This is what i typed into the konsle

    Code:
    $ cd ./cpp/
    $ gcc -o test.cpp
    Your mom is like a struct, she has no class

    How many C programmers does it take to screw in a light bulb? One to do it, 99 to tell him how to do it faster.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,556
    > gcc -o test.cpp
    You're lucky you didn't lose your source file, naming it as the output file.

    g++ test.cpp
    If you want a no-frills compile of a C++ program.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    still a n00b Jaguar's Avatar
    Join Date
    Jun 2002
    Posts
    187

    Re: Compile error

    >> #include <iostream.h>
    >> #include <stdio.h>
    first, don't mix these 2 headers, it's not nice.

    >> #include <iostream.h>
    second, don't put dot-h (.h), only <iostream> is required for this header.

    >> cout << "This is cpp";
    third, you must use std::cout or put...
    using namespace std;
    before main()
    and you forgot "\n" or std::endl at the end.

    >> $ gcc -o test.cpp
    fourth
    $ g++ -o test test.cpp ...for c++ source
    or
    $ gcc -o test test.c ...for c source
    slackware 10.0; kernel 2.6.7
    gcc 3.4.0; glibc 2.3.2; vim editor
    migrating to freebsd 5.4

  4. #4
    Registered User
    Join Date
    Jan 2004
    Posts
    6

    Re: Re: Compile error

    Originally posted by Jaguar
    >> #include <iostream.h>
    >> #include <stdio.h>

    first, don't mix these 2 headers, it's not nice.
    or, if you do, use <cstdio> (and, as mentioned, <iostream> - the ".h" version is obsolete) and be careful about synchronization between the 2 streamsets

  5. #5
    still a n00b Jaguar's Avatar
    Join Date
    Jun 2002
    Posts
    187
    >> or, if you do, use <cstdio>
    This is a Linux forum
    slackware 10.0; kernel 2.6.7
    gcc 3.4.0; glibc 2.3.2; vim editor
    migrating to freebsd 5.4

  6. #6
    Registered User
    Join Date
    Jan 2004
    Posts
    6
    Originally posted by Jaguar
    >> or, if you do, use <cstdio>
    This is a Linux forum
    i see - it's only an issue of 'proper c++ coding' (cleaner namespaces and stuff). still, better leave the lazy coding habits for any leftover windows sessions - linux is about kickass stuff

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. DX - CreateDevice - D3DERR_INVALIDCALL
    By Tonto in forum Game Programming
    Replies: 3
    Last Post: 12-01-2006, 06:17 PM
  4. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  5. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21