// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
#include <iostream>
#include <cstring>

using namespace std;

void Format(char * oneLine){
    char *pSQL = new char[150];
    strcpy (pSQL,"INSERT INTO medlemmer VALUES('");
    char *copy = new char[strlen(oneLine)+1];
    strcpy(copy,oneLine); // important strtok modifies the argument
    char *p = strtok(copy,",");
    strcat(pSQL,p);
    while((p=strtok(NULL,","))!=NULL) {
       strcat(pSQL,"','");
       strcat(pSQL,p);
    }
    strcat(pSQL,"')");
    cout << pSQL << endl;
    delete pSQL;
}

int main() {
   Format("a,bb,ccc");
}
