Luo Yang Meihui 20190912-2 Command Line

This job requires see [ https://edu.cnblogs.com/campus/nenu/2019fall/homework/6582 ]

1. familiar with the command line and console

Please develop applications in C d.exe, read commands from the console command line parameters, respectively, and print out the value of a, b, c in the console. Run the following example the effect of the form (6 points)

>d.exe a=1 b=2 c=3

1

2

3

>d.exe a=11 b=22 c=33

11

22

33

code show as below:

#include <stdio.h>
int main(int argc, char *argv[]){
    int a,b,c;
    sscanf(argv[1], "a=%d", &a);
    sscanf(argv[2], "b=%d", &b);
    sscanf(argv[3], "c=%d", &c);
    printf("%d\n\n",a);
    printf("%d\n\n",b);
    printf("%d",c);
    return 0;
}

 

The results are as follows:

 

Guess you like

Origin www.cnblogs.com/lymh/p/11524354.html