Sujet : Re: OT programming challenge: fastest/best/shortest C program to jumble a sentence, then restore it
De : bowman (at) *nospam* montana.com (rbowman)
Groupes : comp.os.linux.advocacyDate : 09. Mar 2024, 06:07:16
Autres entêtes
Message-ID : <l525jkFqgibU9@mid.individual.net>
References : 1 2 3 4 5 6 7 8
User-Agent : Pan/0.149 (Bellevue; 4c157ba)
On Sat, 9 Mar 2024 03:31:26 -0000 (UTC), vallor wrote:
Seems like a lot of work that could be handled by char sentence[] =
"initializer";
Am I missing something?
No, that works too. Force of habit for me. In a more complicated scenario if you had
void jumble(char* phrase)
{
char* sentence = strdup(phrase);
....
}
you would preserve phrase. In this case after the strtoks if you printf("%s\n", sentence);
you would get 'Once' since strtok() inserts '\0' after each token.