For example, I have a string and I want to write a function that will printf a part of it to the screen with the length printed is not initialized but defined latter wether by function or input data
normally
char str[70]="my name is Jack";
printf("%.4s", str[11])
the result will be "Jack"
However now the length to be written to stdout now is now specified
char str[70]="my name is Jack";
int x;
scanf("%d",&x);
now I the length will be define later so How to use it with printf I now just using this method
char str[70]="my name is Jack";
int x, i;
scanf("%d",&x);
for(i=0, i<x, i++){
printf("%c", str[11+i]);
this will work but I want to know is there any way to printf without using loop. I tried
printf("%.xc", str[11+i]);
but the result is incorrect, so this is not the way.