help with arrays and argv in ANSI C program

This is a discussion on help with arrays and argv in ANSI C program within the C Programming forums, part of the General Programming Boards category; sorry, but I'm really new to programming in general. I need to write a ANSI program to print out each ...

  1. #1
    Registered User
    Join Date
    Mar 2013
    Posts
    1

    help with arrays and argv in ANSI C program

    sorry, but I'm really new to programming in general. I need to write a ANSI program to print out each command line argument on a separate line using a for-loop. also it need to print the name of the executable

    so far I have

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

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,164
    What do you expect the scanf() line to achieve?

    Of less direct relevance to your question, why do your format strings include asterixes?
    Right 98% of the time, and don't care about the other 3%.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Array of pointers and pointer for arrays with argv
    By thames in forum C Programming
    Replies: 4
    Last Post: 12-02-2012, 09:24 AM
  2. need help with testing argv sum program
    By m&m in forum C Programming
    Replies: 5
    Last Post: 07-13-2010, 12:03 AM
  3. Program skips condition which uses argv[]
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 04-12-2002, 02:44 AM
  4. Help on argc, argv program
    By TED22_8 in forum C Programming
    Replies: 3
    Last Post: 01-19-2002, 04:15 PM

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