Home > Back-end >  Global variables in the calling subroutine (sub function of no change of this value) after the chang
Global variables in the calling subroutine (sub function of no change of this value) after the chang

Time:09-26

Novice, for the first time to write a few bigger project, in front of the main function to add a lot of global variables, in the main function of readin sub function called subtab it will change some of the other has nothing to do with the sub function value of the global variables, I ask, what is the row
 
#include
#include
#include
#include
#include
# include "bellmod1. H"
# include "readin1. H"
Int main ()
{
Envfil=fopen (" env. TXT ", "r");
Prtfil=fopen (" prtfil. TXT ", "w");
Elfil=fopen (" EL. TXT ", "w");
Readin ();
//the end
}

 
# # ifndef BELLMOD1_H_INCLUDED
# define BELLMOD1_H_INCLUDED
# define PI 3.14159265
The FILE * shdfil, * rayfil;
The FILE * arrfil;
The FILE * atifil;
The FILE * btyfil;
The FILE * envfil, * prtfil;
The FILE * sbpfil;
Trcfil brcfil FILE * and * and * ircfil;
The FILE * rlfil;
The FILE * elfil;


//the main
Const int maxn=300000;
Double degrad=PI/180.0;
Double raddeg=180/PI;
Double _Complex ci=0.0 + 1.0 * I;
Int arrivalsstorage=20000000;
Int ibeam;
Double H;
O_smooth double i_smooth [10000], [10000], oo_smooth [10000].
//sonar equation part
Tl_f double rl_f [501] [10000], [501] [10000].
Double el [10000];
Double SRR [10000].
Int sonartype tstype, bjtype bottype, sctype;
Double sl and tl, nl, di, dt, ts;
Double STDD, SNDD;
Double utl;//the critical pressure


//readin
Int NSD, NRD, nr, ntheta;
Rd double sd [10], [501], rd1 [501], r [8001].
Double theta [10000].
Int nr1 nrd1;
Int allocatestatus nmedia, NPTS;
Char title [80]. Double freq, fl, fh; Const int isingl=0;
Int nimage ibwin; Int MXN; Double zbox; Double rbox;
Double epmult; Double rloop; Char topopt [8]=""; Char component;
Char botopt [8]="";
Char runtype [8]=""; Char beamtype [8]="";
Char runtype1 [8]="";
Int nbeams; int i;
Double alpha [5000];//alpha (nbeams)
Bctype char ssptype [1], [1], atunit [1].

Double c0=1500.0;
Double lambdax10 lambdax66;
Eta=double freqd bumden=0.0, 0.0, xi=0.0, sigma=0, dby20;
Char filename [8]="";
Double ZTMP;
Double alphar=1500.0;
Double betar=0.0;
Double rhor=1.0;
Double alphai=0.0;
Double betai=0.0;
Char plottype [12]="";
Double atten.


 
# # ifndef READIN1_H_INCLUDED
# define READIN1_H_INCLUDED
# include "errout1. H"
# include "spliner1. H"
# include "subtub1. H"
# include "sort1. H"
# include "writeheader1. H"
Double readin ()
{
//stick not bottom, front omit
Subtab (r, nr);//has nothing to do is call the sub function always change the global variable values
Sort1 (r, nr);
}

CodePudding user response:

There is only one case, this phenomenon is crossing the line, check on your own, single step debugging,
  • Related