其他分享
首页 > 其他分享> > main函数 参数解析

main函数 参数解析

作者:互联网

int index = 1;
    while(index < argc){
        if(strcmp(argv[index], "-d") == 0){
            index += 1;
            directory = (char*) malloc(strlen(argv[index]));
            strcpy(directory, argv[index]);
         
        }
        else if(strcmp(argv[index], "-ra") == 0){
            index += 1;
            rowa = atoi(argv[index]);
           
        }
        else if(strcmp(argv[index], "-rb") == 0){
            index += 1;
            rowb = atoi(argv[index]);
         
        }
        else if(strcmp(argv[index], "-ca") == 0){
            index += 1;
            cola = atoi(argv[index]);
        }else if(strcmp(argv[index], "-cb") == 0){
            index += 1;
            colb = atoi(argv[index]);
          
        }
        index += 1;

    }

 

标签:index,解析,函数,argv,else,atoi,directory,main,strcmp
来源: https://www.cnblogs.com/bohrchen/p/16113759.html