// 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('");
    int ix = strlen(pSQL);
    for(int i=0;i<strlen(oneLine);i++) {
        if(oneLine[i]==',') {
            pSQL[ix]='\'';
            ix++;
            pSQL[ix]=',';
            ix++;
            pSQL[ix]='\'';
            ix++;
        } else {
            pSQL[ix]=oneLine[i];
            ix++;
        }
    }
    pSQL[ix]='\0';
    strcat(pSQL,"')");
    cout << pSQL << endl;
    delete pSQL;
}

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