예제 #1
0
int main(int argc, char *argv[]) 
{
	if( argc == 3 )
  	{
      	printf("The argument supplied is %s\n", argv[2]);
   	}
   	else if( argc > 3 )
   	{
      	printf("Too many arguments supplied.\n");
   	}
   	else
   	{
      	printf("Three argument expected.\n");
   	}

	char *textFile = argv[1];
	char *binaryFile  = argv[2];
    int return_status = binconv(textFile, binaryFile); /* assumes a value for successful completion, i.e. 0 in case of success and 1 in
 	case of failure */

        if ( return_status !=0 ){

               printf("Data file to Binary file conversion failed \n");
               return EXIT_FAILURE; 
	    }

       return EXIT_SUCCESS; 

}
예제 #2
0
int main(int argc, char *argv[]) {

	char *input_file, *output_file;

	/* the program needs to be called as:
	 * binconv <input_file> <output_file>
	 */

	if (argc != 3){
			printf("Wrong parameters! Exit!!\n");
			exit(1);
			}

	if(strcmp(get_filename_ext(argv[1]), "dat")!=0){
			printf("First argument must be a dat file\n");
			exit(1);
			}
	if(strcmp(get_filename_ext(argv[2]), "bin")!=0){
			printf("Second argument must be a bin file\n");
			exit(1);
			}
	
	input_file = argv[1];
	output_file = argv[2];
	


	binconv(input_file, output_file);

	printf("%s created\n", output_file);
	return 0;
}