I have a contrived example to demonstrate the request for a specific functionality - I wonder if anyone has a clever trick to do this.
The following is a problem one
Here's a way that requires a separate initialization pass, but that has a slightly cleaner for loop. Array sepsarray holds the separators you want (in this example, commas so you can see them). The last element of sepsarray is followed by a '\0' that terminates the loop.
#include
#define MAXNUM 5
//print up to this
void main() {
char sepsarray[256] = {0}; //256=arbitrary max size
int i;
char *seps=sepsarray;
for(i=0;i
Output:
0,1,2,3,4,5
Hardly IOCCC material, but hey... :)