Let's say I have a file called "____.srt" , where ___ could be anything. I'm trying to change its name, by adding '1' , so it'll look like this "____1.srt".
The file is read from an argument using CMD, argv[1].
void main(int argc,char* argv[]){
char* pt;
pt = strstr(argv[1],".srt\0"); // checks if end of input-string is .srt
if( pt == NULL)
{
fprintf(stdout,"Invalid input.\nInput file must be inputfile.srt\n");
fprintf(stdout,"Program will now exit\n");
return;
}
strcpy(pt,'1');
strcat(argv[1],".srt");
fprintf(stdout,"%s file was created.\n",argv[1]); }
This doesn't seem to work. Can someone figure out the problem? I'd appreciate any help. Thank you