Menu

batch file code problem !!

prog77
2008-08-02
2012-09-26
  • prog77

    prog77 - 2008-08-02

    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

     
    • cpns

      cpns - 2008-08-02

      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

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.