Compile C++

This is a discussion on Compile C++ within the C Programming forums, part of the General Programming Boards category; I can compile following code using "cl A.cpp" but i want to compile with an input file A.in and generate ...

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    1

    Compile C++

    I can compile following code using "cl A.cpp" but i want to compile with an input file A.in and generate output file A.out.. is there any why to do that from cmd....


    A.cpp

    Code:
    #include<stdio.h>
    
    int main(){
        int n;
        while( scanf("%d", &n) ){
            if( !n )break;
            printf("%d\n", n);
        }
        return 0;
    }
    A.in
    Code:
    1
    2
    3
    4
    5
    0

  2. #2
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,498
    Well.. you could use redirection.
    Write your program to use cout and cin(or printf and scanf..) for I/O ..and then.. when running; use the command.
    Code:
    ./executable <input_file >output_file
    But how you got the idea that you can compile with A.in file and produce A.out `s is 'suspicious' ! ..(If you saw a.out as the executable... then remember that it is just an executable format...not something your program produces. )
    Last edited by manasij7479; 10-28-2011 at 01:12 AM.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,457
    What did you not post this in the C section?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,453
    > I can compile following code using "cl A.cpp"
    You could, but what you've written is all C.
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Does C# compile to an exe?
    By thetinman in forum C# Programming
    Replies: 7
    Last Post: 11-21-2008, 10:17 AM
  2. compile once, compile twice ...error
    By Benzakhar in forum Windows Programming
    Replies: 6
    Last Post: 12-28-2003, 05:00 AM
  3. Replies: 3
    Last Post: 03-07-2003, 08:06 PM
  4. Won't compile, can YOU compile it on your compiler?
    By incognito in forum C++ Programming
    Replies: 12
    Last Post: 03-10-2002, 11:00 AM

Tags for this Thread


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