fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. char name[5]; // 4 chars + null terminator
  5.  
  6. printf("Enter the first four letters of your name:\n");
  7.  
  8. scanf(" %c", &name[0]);
  9. scanf(" %c", &name[1]);
  10. scanf(" %c", &name[2]);
  11. scanf(" %c", &name[3]);
  12.  
  13. name[4] = '\0';
  14.  
  15. printf("You entered: %s\n", name);
  16.  
  17. return 0;
  18. }
  19.  
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
Enter the first four letters of your name:
You entered: �