fork(1) download
  1. #include <stdio.h>
  2.  
  3. const int kMaxLength = 30;
  4.  
  5. int main() {
  6. int i, j;
  7. char family[kMaxLength + 1];
  8. char first[kMaxLength + 1];
  9. char fullname[kMaxLength * 2 + 1 + 1];
  10.  
  11. printf("Family name: ");
  12. scanf("%s", family);
  13. printf("First name: ");
  14. scanf("%s", first);
  15.  
  16. for (i = 0; family[i]; i++) {
  17. fullname[i] = family[i];
  18. }
  19. fullname[i++] = ' ';
  20. for (j = 0; first[j]; i++, j++) {
  21. fullname[i] = first[j];
  22. }
  23. fullname[i] = '\0';
  24.  
  25. printf("%s\n", fullname);
  26.  
  27. return 0;
  28. }
  29.  
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:12: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
prog.c:14: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
stdout
Family name: First name: o��