hello,
i have a struct and have declared it as shown below. If i print its value in the main() fn it prints it correctly.Howev er if i declare the struct again in the main() and try to print its value it doesnot give me the correct value but prints some garbage value. Why is it so? Is there any way to correct it because i think i have to declare it again in main() for initializing other variables.
thanks,
prads
i have a struct and have declared it as shown below. If i print its value in the main() fn it prints it correctly.Howev er if i declare the struct again in the main() and try to print its value it doesnot give me the correct value but prints some garbage value. Why is it so? Is there any way to correct it because i think i have to declare it again in main() for initializing other variables.
thanks,
prads
Code:
#include <iostream>
#include <fstream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
struct set
{
long int mstoprocess;
int noofchannels;
int skipnoofbytes;
}settings={37000,8,0};
int main()
{
int i;
static struct set settings; //if this is removed it works fine!!!!
cout<<settings.mstoprocess<<endl;
getchar();
return 0;
}
Comment