Opening Multiple Files in sequence

This is a discussion on Opening Multiple Files in sequence within the C++ Programming forums, part of the General Programming Boards category; Hi all, I am new to C++ and i have a question. Is there any way that i can open ...

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    4

    Opening Multiple Files in sequence

    Hi all,

    I am new to C++ and i have a question.

    Is there any way that i can open multiple files in sequence and displaying the info onto the screen in sequence also. For example, loading for multiple picture files and forming them into an animation?

    Anyone can help?


    Thanks in advance

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,422
    Sure, how much of that can you do already?

    Code:
    #include <iostream>
    int main ( int argc, char *argv[] ) {
      for ( int i = 1 ; i < argc ; i++ ) {
        std::cout << "parameter " << i << " is " << argv[i] << std::endl;
      }
    }
    If you compile and run this program with say
    ./myprog.exe *.jpg
    in a directory with lots of jpg files, you'll see them all listed.

  3. #3
    Registered User
    Join Date
    Jan 2006
    Posts
    4

    Smile

    Hi thanks for your quick reply,

    I am a newbie to c++ programming. The last time i tried programming was 7 years back.

    May I know how this works?
    Code:
    std::cout << "parameter " << i << " is " << argv[i] << std::endl;

    I tried to compile but it gave me a error C2601: 'main' : local function definitions are illegal

    here is my code

    Code:
     
    #include "stdafx.h"
    #include <iostream>
    
    int APIENTRY WinMain(HINSTANCE hInstance,
                         HINSTANCE hPrevInstance,
                         LPSTR     lpCmdLine,
                         int       nCmdShow)
    {
     	int main ( int argc, char *argv[] ) 
    	{
    		for ( int i = 1 ; i < argc ; i++ ) 
    		{ 
    		std::cout << "parameter " << i << " is " << argv[i] << std::endl;
    		}
    	}
    
    	return 0;
    }
    really appreciate for the help

  4. #4
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    You've included a main function in a WinMain function, use one or the other. If you're making a console application use main or use WinMain for a GUI application.

    Also, Salem
    Quote Originally Posted by Salem
    If you compile and run this program with say
    ./myprog.exe *.jpg
    in a directory with lots of jpg files, you'll see them all listed.
    To do that you would need to implement directory parsing, I'm not aware of any OS that will produce multiple arguments for you.

  5. #5
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Quote Originally Posted by Quantum1024
    To do that you would need to implement directory parsing, I'm not aware of any OS that will produce multiple arguments for you.
    A proper shell will expand the arguments. Windows cmd.exe doesn't.
    Kurt
    Last edited by ZuK; 01-14-2006 at 02:47 AM.

  6. #6
    Registered User
    Join Date
    Jan 2006
    Posts
    4
    okie thanks the advice guys.
    i will go try it

  7. #7
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    >> i will go try it

    Go try what?

  8. #8
    Registered User
    Join Date
    Jan 2006
    Posts
    4
    to try out the codes to see if it works


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Notepad++ opening ActionScript files
    By sean in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 08-26-2008, 03:49 PM
  2. Replies: 5
    Last Post: 02-25-2008, 05:35 AM
  3. opening files sequentially
    By barneygumble742 in forum C++ Programming
    Replies: 9
    Last Post: 12-21-2006, 10:26 AM
  4. Windows shell commands - multiple files
    By Magos in forum Tech Board
    Replies: 3
    Last Post: 02-28-2006, 12:56 AM
  5. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 01:41 PM

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