Incomplete argv/argc when using FTYPE and ASSOC

This is a discussion on Incomplete argv/argc when using FTYPE and ASSOC within the Windows Programming forums, part of the Platform Specific Boards category; I'm trying to use a standard C main() program with FTYPE and ASSOC. The main.c program is: Code: main(argc,argv) int ...

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    2

    Incomplete argv/argc when using FTYPE and ASSOC

    I'm trying to use a standard C main() program with FTYPE and ASSOC.

    The main.c program is:

    Code:
    main(argc,argv) 
    int argc; 
    char **argv; 
    { 
    int i; 
    
    
    printf("argc = %d\n", argc); 
    
    
    for(i=0; i<argc; i++) 
    printf ("argv[%d] = %s\n", i, argv[i]); 
    
    }

    And I use in a DOS windows:

    Code:
    ASSOC .ma=MainScript 
    FTYPE MainScript=main.exe %1 %*

    If I call the program in this way:

    Code:
    testma.ma 1 2 3
    I only get:

    Code:
    argc = 2 
    argv[0] = main.exe 
    argv[1] = testma.ma

    The command line arguments ("1", "2" and "3") here are not visible in
    argc/argv.

    How do I retrieve these arguments in the C program?

    Thank you in advance for any help.

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,627
    The arguments aren't passed to your program. The problem lies elsewhere.
    Your code is very poorly indented and might need some help:
    http://cpwiki.sf.net/Indentation
    Code:
    main(argc,argv) 
    int argc; 
    char **argv;
    Is incorrect syntax.
    It should be
    Code:
    int main(int argc, char** argv)
    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.

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    2
    Quote Originally Posted by Elysia View Post
    The arguments aren't passed to your program. The problem lies elsewhere.
    I know, that's my problem!

    Using exactly the same FTYPE and ASSOC syntax with other commercial programs (like the Hamilton C-Shell) works, they do get the arguments.

    So, I'm stumped. I just can't figure it out.

    Your code is very poorly indented and might need some help:
    That was just a quick sample to reproduce the problem I have with the real application.

    Thanks.

  4. #4
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,627
    Nevertheless, indentation is important and should never be left out. Even if it just a demonstration or sample code.
    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.

Popular pages Recent additions subscribe to a feed

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