cin.getline is c++ not c.
scanf( "%[^\n]", name );
will read until a newline is encountered. For that reason you'll have to clear the buffer before using it -
Code:
#include <stdio.h>
#include <stdlib.h>
char name[50];
int selection;
int write_name(void)
{
int c;
// clrscr(); doesn't work on my compiler
printf("What is your name?");
while ((c = getc(stdin)))
if (c == '\n')
break;
scanf("%49[^\n]",name);
printf("\n%s",name);
return 0;
}
int main(void)
{
scanf("%d",&selection);
switch(selection)
{
case 0:
write_name();
break;
}
return 0;
}