I'm trying to test the ->
operator, but I can't seem to do that, because when I execute the following program and feed the input with a stream, the program stops working.
Note1: I get a warning before compiling, it says that:
format '%s' expects argument of type 'char *', but argument 2 has type 'int' [-Wformat=]
Note2: if I omit the line printf("%s\n", *(&home1)->name )
, it works just fine, and actually prints whatever I wrote.
#include <stdio.h>
#include <string.h>
typedef struct home_type {
char name[30] ;
}home;
int main (void) {
home home1 ;
char name[30] ;
scanf ("%[^\n]%*c", name);
strcpy( home1.name, name) ;
printf("%s\n", home1.name ) ;
printf("%s\n", *(&home1)->name ) ;
return 0 ;
}