Write a C program that will print out each command line argu

Write a C program that will print out each command line argument on a separate line. Use a for-loop. The loop should have an index variable i that ranges from 0 to (argc-1). Remember the first command line argument is called argv [0] and its type is string so you can print it out with a %s format code. You should also recall that the character combination \ means newline. Name your program assignment05pe01. c and save it within directory/.../S17Courses/1010/assignment05

Solution

#include <stdio.h>

int main( int argc, char *argv[] ){
   int i;
   printf(\"Total number of arguments = %d\ \", argc);
   for(i=0;i<argc;i++)
       printf(\"The argument %d supplied is %s\ \", i+1,argv[i]);
}

Output url : http://ideone.com/e8TCdq

 Write a C program that will print out each command line argument on a separate line. Use a for-loop. The loop should have an index variable i that ranges from

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site