fork download
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3.  
  4. void print_name(char *s){
  5. /* s が空白に到達するまでポインタを進める */
  6. while (*s != ' ') {
  7. s++;
  8. }
  9.  
  10. /* s は現在 ' ' を指しているので、名は s+1 から始まる */
  11. printf("%s", s + 1);
  12. }
  13.  
  14. int main(void){
  15. char *name = "Okamoto Taro";
  16.  
  17. printf("こんにちは,");
  18. print_name(name);
  19. printf("さん\n");
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0s 5300KB
stdin
Standard input is empty
stdout
こんにちは,Taroさん