Update m4s_to_mp4:Change 'fgets to std::cin.getline()'

This commit is contained in:
daleclack 2021-03-16 14:23:03 +08:00
parent 061faa2006
commit fd2750a7c9
1 changed files with 8 additions and 17 deletions

View File

@ -1,34 +1,25 @@
#include <iostream>
#include <cstdio>
#include <thread>
#include <cstring>
#include <cstdlib>
void clear(char str[]){
if(strlen(str)==0) return;
int i=0;
while(str[i]!='\n'){
i++;
}
str[i]='\0';
}
int main(int argc,char *argv[]){
char command[10000],filename1[1000],filename2[1000],output[1000];
//Get file 1 filename
printf("Input file1 name:");
fflush(stdin);
fgets(filename1,sizeof(filename1),stdin);
clear(filename1);
std::cin.getline(filename1,sizeof(filename1));
//Get file 2 filename
printf("Input file2 name:");
fflush(stdin);
fgets(filename2,sizeof(filename2),stdin);
clear(filename2);
std::cin.getline(filename2,sizeof(filename2));
//Get output file name
printf("Input output name:");
fflush(stdin);
fgets(output,sizeof(output),stdin);
clear(output);
//printf("%s\n%s",filename1,filename2);
std::cin.getline(output,sizeof(output));
//Generate command and execute the command
sprintf(command,"ffmpeg -i \"%s\" -i \"%s\" -codec copy \"%s\"",filename1,filename2,output);
//printf("%s",command);
std::thread first (system,command);
first.detach();
getchar();