Sunday, January 24, 2010

How to feed input from a text file into a CPP File without using File Handling

1. Initial syntax in the program should be to  read a data into a variable repeatedly.
    Example:
    int main()
    {
                int A;
                while(cin>>A)
                {
                            .
                            .
                            .
                }
                return 0;
    }
2. Create an input text file containing the input in the prescribed format.
    Example: Say the input text file is named input.
3. Save the text file in a directory.
    Example: Documents.
4. Open command prompt.
5. Reach the directory using suitable commands.
    Example:
    C:\Users\Sourabh-PC>cd Documents
6. Now the command is Filename.exe<input.txt>output.txt
    Example:
    C:\Users\Sourabh-PC\Documents>Snowfall.exe<input.txt>output.txt
7. This creates a text file named output in the same directory containing the output.

No comments:

Post a Comment