the posted code contains several problems:
Most of those problems are covered in the question comments.
The following code compiles cleanly and performs the desired function
#include <stdio.h> // printf()
#include <stdlib.h> // system()
int main( void )
{
int i;
for (i=0; i<9; i++)
{
printf("pinging device number:%d\n",i);
system( "ping6 fe80::acbd:ff:fe00:i%nstack -c 2" );
}
printf(" \n Done\n");
}
the output from the above code is:
pinging device number:0
unknown host
pinging device number:1
unknown host
pinging device number:2
unknown host
pinging device number:3
unknown host
pinging device number:4
unknown host
pinging device number:5
unknown host
pinging device number:6
unknown host
pinging device number:7
unknown host
pinging device number:8
unknown host
Done
You may be able to reach a valid host from your network.
However, remember the excerpt from the man page about not being able to perform routing.
(edit) the following code cleanly compiles and uses sprintf()
However, I find nothing that supports the 6th address :1%nstack
parameter! I would expect to only see the device number, not the text: %nstack
what am I missing?
#include <stdio.h> // printf(), sprintf()
#include <stdlib.h> // system()
int main( void )
{
int i;
char pingCmd[100] = {'\0'};
for (i=0; i<9; i++)
{
printf("\npinging device number:%d\n",i);
//system( "ping6 fe80::acbd:ff:fe00:i%nstack -c 2" );
sprintf( pingCmd, "%s%d%s", "ping6 -c 2 fe80::acbd:ff:fe00:", i, "%nstack");
printf( "%s\n", pingCmd);
system( pingCmd );
}
printf(" \n Done\n");
}
the output from the above is:
pinging device number:0
ping6 -c 2 fe80::acbd:ff:fe00:0%nstack
unknown host
pinging device number:1
ping6 -c 2 fe80::acbd:ff:fe00:1%nstack
unknown host
pinging device number:2
ping6 -c 2 fe80::acbd:ff:fe00:2%nstack
unknown host
pinging device number:3
ping6 -c 2 fe80::acbd:ff:fe00:3%nstack
unknown host
pinging device number:4
ping6 -c 2 fe80::acbd:ff:fe00:4%nstack
unknown host
pinging device number:5
ping6 -c 2 fe80::acbd:ff:fe00:5%nstack
unknown host
pinging device number:6
ping6 -c 2 fe80::acbd:ff:fe00:6%nstack
unknown host
pinging device number:7
ping6 -c 2 fe80::acbd:ff:fe00:7%nstack
unknown host
pinging device number:8
ping6 -c 2 fe80::acbd:ff:fe00:8%nstack
unknown host
Done