#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

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);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.