0
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>

int main(){
    int i = 2;
    char a[1];
    itoa(i, a, 10);
    
    char *command = ("md %s", a);
    
    system(command);
   
   char *cop = ("copy %s.jpg \%s\%s.jpg" , a, a, a); // want to copy the jpg file in to 
    system(cop);                                //new made folder the path as (2/2.jpg)
    getch();
    return 0;
    system("pause");
}

but this doesnt work as I expected. what is the error here. I think we can't parse values using %s . So what should I do..
plz help

2
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by itsmeisuru
1

it doesn't work because you have to use sprintf() to format the string.

char command[255] = {0};
sprintf(command,"copy %s.jpg \\%s\\%s.jpg" , a, a, a);

Edited by Ancient Dragon: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.