Thread: help with arrays and argv in ANSI C program

  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,815
    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%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

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, 10: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, 05:15 PM

Tags for this Thread