srand(GetTickCount()); int randlen = (rand()%3)+7; int i; for ( i=0; i < randlen; i++) buffer[i] = (rand()%26)+97; buffer[i] = '\0'; printf(buffer);