-2

So I used this code in order to pass a variable in to my struct:

strcpy(s[i].orderName, Name);

and it works how I want it to. However, the rest of my variables are integers and a double and it appears there is no "intcpy()" alternative from what I have found. Is there another way to pass integer and double variables in to my struct?

Thank you.

Ibrahim
  • 75
  • 7

1 Answers1

2

You can use a simple assignment = for the int variables:

struct abc {
    int a;
    int b;
};

void foo(int b)
{
    struct abc x;

    x.a = 8;
    x.b = b;


    printf("x.a: %d\n, x.b: %d\n", x.a, x.b);
}
Pablo
  • 13,271
  • 4
  • 39
  • 59