I want command line which should print in batch file like
"Copy C:\Program Files\Direct\Input\Prog%d.IN Prog.In" as if its not in inverted commans i ll get prblem becoz of space between program and files word while running it . but when i try to do .. i m not gettin inverted commas in my file.bat and also if i try to give double commas still i m not gettin it .. can someone tellme how can i get that command line with in inverted commas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi ,
I am writing a batch file program in c++ . to create a batch file with commands in it .
include<stdio.h>
include<string.h>
using namespace std;
main()
{
FILE * fp;
int i=1;
fp = fopen ( "file.bat","w");
for(i=1;i<=10;i++){
fprintf(fp,"Copy C:\Program Files\Direct\Input\Prog%d.IN Prog.In\n",i);
fprintf(fp,"\n");
}
fclose(fp);
I want command line which should print in batch file like
"Copy C:\Program Files\Direct\Input\Prog%d.IN Prog.In" as if its not in inverted commans i ll get prblem becoz of space between program and files word while running it . but when i try to do .. i m not gettin inverted commas in my file.bat and also if i try to give double commas still i m not gettin it .. can someone tellme how can i get that command line with in inverted commas
To place a " character in a string literal, you must use the \" escape sequence.
fprintf(fp,"Copy \"C:\Program Files\Direct\Input\Prog%d.IN Prog.In\n\"",i);
More on C/C++ escape sequences: http://www.cppreference.com/escape_sequences.html
Clifford