A problem asks me to make a printf statement which will print out the members of the struct given, I wrote a program to make sure I would get the right printf statement.

#include <stdlib.h>
#include <stdio.h>

int main()
{
   struct house
   {
5.    char style[40];
      int rooms;
      float price;
   }*hPtr;

10.   (*hPtr).style = "abc";
   (*hPtr).rooms = 4;
   (*hPtr).price = 10.0; /*values were used so that printf is possible*/
13.   printf("%s %d %f\n", (*hPtr).style, (*hPtr).rooms, (*hPtr).price);
  return 0;
}

however i get the error
test.c.13: error: incompatible types in argument
what am i missing?

>(*hPtr).style = "abc";
You don't copy arrays like this. You also don't compare arrays with the relational operators either. Further, at this point hPtr doesn't point to anything. You need to point it to an address that you own:

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

int main()
{
    struct house
    {
        char style[40];
        int rooms;
        float price;
    } h, *hPtr;

    hPtr = &h;
    strcpy ( (*hPtr).style, "abc" );
    (*hPtr).rooms = 4;
    (*hPtr).price = 10.0; /*values were used so that printf is possible*/
    printf("%s %d %f\n", (*hPtr).style, (*hPtr).rooms, (*hPtr).price);
    return 0;
}
This question has already been answered. Start a new discussion instead.