fork(1) download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. char lastName(char* name);
  5.  
  6. int main(){
  7.  
  8. char* start[10];
  9. char* name[20];
  10.  
  11. printf("Type your first name: ");
  12. scanf(" %s", &start);
  13. strcpy(name, start);
  14.  
  15. printf("\n");
  16.  
  17. if(strlen(name) > 0){
  18. lastName(name);
  19. }
  20. }
  21.  
  22. char lastName(char* name){
  23.  
  24. char* last[20];
  25. int length;
  26. printf("Type your last name: ");
  27. scanf(" %s", &last);
  28. printf("\n");
  29. strcat(name, last);
  30. length = strlen(name);
  31. printf("Your full name is %s and it has %d characters," &name, length);
  32. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function 'main':
prog.c:12:8: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char * (*)[10]' [-Wformat=]
  scanf(" %s", &start);
        ^
prog.c:13:9: warning: passing argument 1 of 'strcpy' from incompatible pointer type [-Wincompatible-pointer-types]
  strcpy(name, start);
         ^
In file included from prog.c:2:0:
/usr/include/string.h:129:14: note: expected 'char * restrict' but argument is of type 'char **'
 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
              ^
prog.c:13:15: warning: passing argument 2 of 'strcpy' from incompatible pointer type [-Wincompatible-pointer-types]
  strcpy(name, start);
               ^
In file included from prog.c:2:0:
/usr/include/string.h:129:14: note: expected 'const char * restrict' but argument is of type 'char **'
 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
              ^
prog.c:17:12: warning: passing argument 1 of 'strlen' from incompatible pointer type [-Wincompatible-pointer-types]
  if(strlen(name) > 0){
            ^
In file included from prog.c:2:0:
/usr/include/string.h:399:15: note: expected 'const char *' but argument is of type 'char **'
 extern size_t strlen (const char *__s)
               ^
prog.c:18:12: warning: passing argument 1 of 'lastName' from incompatible pointer type [-Wincompatible-pointer-types]
   lastName(name);
            ^
prog.c:4:6: note: expected 'char *' but argument is of type 'char **'
 char lastName(char* name);
      ^
prog.c: In function 'lastName':
prog.c:27:8: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char * (*)[20]' [-Wformat=]
  scanf(" %s", &last);
        ^
prog.c:29:15: warning: passing argument 2 of 'strcat' from incompatible pointer type [-Wincompatible-pointer-types]
  strcat(name, last);
               ^
In file included from prog.c:2:0:
/usr/include/string.h:137:14: note: expected 'const char * restrict' but argument is of type 'char **'
 extern char *strcat (char *__restrict __dest, const char *__restrict __src)
              ^
prog.c:31:58: error: invalid operands to binary & (have 'char *' and 'char *')
  printf("Your full name is %s and it has %d characters," &name, length);
                                                          ^
prog.c:32:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
stdout
Standard output is empty