title: Switch Statements Using String Input
body: <pre><code>char type;
  printf("What type of sort would you like to perform?\n");
  scanf("%s", &amp;type);
  switch(type)
  {
  case 'bubble':
      bubble_sort();
  case 'selection':
  case 'insertion':
  default:
      printf("invalid input\n");
  }
  </code></pre>
  
  <p>I am trying to create a program which sorts a list with either bubble, selection, or insertion sort based on the user's input. </p>
  
  <p>I have to use switch case to do so. </p>
  
  <p>I have defined a variable "type" before the switch statement, and then use the scanf function to assign it either "bubble", "selection", or "insertion". </p>
  
  <p>However, when I run the code and type in "bubble", it does not carry out my bubble_sort function (not shown here) and instead resorts to the default case. </p>
  
  <p>How can I fix this issue? </p>
  
  <p>I am slightly uncertain as to whether 'char' was the correct way to define my "type" variable, or whether switch statements can only be used with single characters.</p>
  
  <p>Also, I apologise if my code is not formatted correctly, as I am new to this site. </p>
  
  <p>Let me know if I need to add any more information to this question!</p>