ss2=ss1; this will depend on the compiler some compiler will allow to copy the structure variable and some not.
ss2.x=st1.a; ss2 structure will be local to the main function and it is not available in funct1(), so it must be throwing the compilation error.
Confusion with structure variable in C++ [closed]
Frage
Is it possible to assign value of one structure variable to another structure variable Is this code correct -
#include<iostream.h>
struct s1
{
int a;
float b;
char c;
} st1,st2,st3;
int main()
{
struct s2{
int x;
float y;
char z;
} ss1,ss2,ss3;
// Read & Initialize structures
ss2=ss1;
:
ss3.z=st1.c;
:
}
void func1()
{
ss2.x=st1.a;
ss3.y=st2.b;
ss1.z=st3.c;
:
ss1=ss3;
}
Kindly clear my doubt whether the above code is OK or not
Lösung
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow