Please check out this program.
#include<stdio.h> #include<string.h> typedef struct hs_ims_msrp_authority { int host_type; char buf[50]; int port; }hs_i; int main() { char dom[50]; int i = 10, j = 20; strcpy(dom, "ine"); fun((hs_i){i, dom, j}); // doesnt work fun((hs_i){i, "dom", j}); // this works } int fun(hs_i c) { printf("%d %s %d\n", c.host_type, c.buf, c.port); }
In the fun function call in main; how does a function call work when a string literal ("dom") is passed, where, when an array variable (dom) is passed, does it not work?
To do work with variables, should it be typed in a certain way? or is there any other way?
source share