Thread: command line arguments on Solaris 7

  1. #1
    Unregistered
    Guest

    command line arguments on Solaris 7

    I have a simple program as follows:

    #include <stdio.h>

    int main(int argc, char *argv[])
    {
    int x;

    for (x=0; x<argc; x++)
    printf("arg0=%s", argv[x]);

    exit(0);
    }

    If I compile and run on windows when I pass parameters they display, however, they do not display when I compile and run on Solaris 7 using gcc. If I print argc, it equals 0 even if I pass in values. Is there something I'm missing on unix?

    Thanks,

    Todd Hahn.
    [email protected]

  2. #2
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    Output isn't always flushed unless you send in the newline charecter or you use fflush(stdout). Also to use the exit
    function call I think you are supposed to #include <stdlib.h>

    Code:
    #include <stdio.h> 
    
    int main(int argc, char *argv[]) 
    { 
         int x; 
    
         for (x=0; x<argc; x++) 
               printf("arg0=%s\n", argv[x]); 
    
         return 0;
    }

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. GradeInfo
    By kirksson in forum C Programming
    Replies: 23
    Last Post: 07-16-2008, 03:27 PM
  3. command line arguments
    By vurentjie in forum C Programming
    Replies: 3
    Last Post: 06-22-2008, 06:46 AM
  4. Replies: 10
    Last Post: 09-27-2005, 12:49 PM
  5. NULL arguments in a shell program
    By gregulator in forum C Programming
    Replies: 4
    Last Post: 04-15-2004, 10:48 AM