c++ - Cin failing to execute following the first iteration of loop -


I have a loop that can be used by the user for input using std :: cin In order to get the distance between the two longitude / latitude points, however, after the first repetition of the loop, fails to execute std :: cin and then to run before the loop Using the stored variable at

  # include & lt; Iostream & gt; #include & lt; string & gt; #to & lt include, cmath & gt; #to & lt include, sstream & gt; #to & lt include, vector & gt; #to & lt include, iterator & gt; using namespace std; Int main () {string start position; Int numDest; String arrowstart [3]; Gateline (pin, starting position); Stringstream ssinStart (initial position); Int k = 0; String airport = ""; While (ssinStart.good () & amp; amp; amp; amp; amp; amp; amp;; & lt; 3) {if (k & lt; 2) {ssinStart> & Gt; ArrStart [k]; ++ k; } And {string mid; SsinStart & gt; & Gt; Middle; ArrStart [k] .append (middle); Arrest [K]. Append (""); }} Cin & gt; & Gt; NumDest; String * destinations = new string [numDest]; Double * distDest = new double [numDest]; String Dest; {Cin & gt; for Int ii = 0; I & lt; numDest; i ++) & Gt; Destination; String arrDest [3]; Stringstream ssinDest (lost); Int j = 0; While (ssinDest.good ()) and J & LT; 3) {if (j & lt; 2) {ssinDest & gt; & Gt; ArrDest [J]; ++ j; } And {string mid; SsinDest & gt; & Gt; Middle; Destinations [i] .append (center); Destination [i] .append (""); }} String delimiter = "/"; Double latte 1 = Atf (ARR start [0]. Sbststst (0, ARRstart [0] .fund (delimiter)). C_str ()); Double Lat 2 = Atf (ARDist [0]. Sbstust (0, ARMRST [0] .fund (delimiter)). C_str ()); Double loan 1 = etf (Arrestart [1] .substr (0, ARARSTART [1] .fund (delimiter)) .c_str ()); Double loan 2 = etf (ARDist [1]. Sbstreet (0, ARMST [1] .fund (delimiter)). C_str ()); If (* Arrest [0]. RBIGi (== 'S') {lat1 = -lat1; } If (* arrDest [0]. Rbegin () == 's') {lat2 = -lat2; } If (* Arrestart [1]. Rebeccin () == 'W') {lon1 = -lon1; } If (* ARDist [1] .rbine (== 'W') {lon2 = -lon2; } Double DLT = Lot 1 - Lat 2; Double Dublin = Loan 1 - Loan 2; Double r = 3959.9; Double A = Pove (sin (dlat / 2), 2) + cos (lat 1) * cos (lat 2) * pot (sin (dublan / 2), 2); Double C = 2 * Eton2 (SQLT (A), SQLT (1-A)); Double d = r * c; DistDest [i] = D; } (Int i = 0; i  

Input takes the initial space, then the number of destinations (3 in this case), then the user should point to input 3 space. However, after inputting the first place, it is repeated through the loop, the number of remaining time then output to the pair at the end (which falls on one another). I am assuming that this is a memory issue because the variable defined inside the loop is being done between iterations, but I have no luck on this issue.

I

  15 9 .123 / N 145.22 / W Los Angeles 3 124.22 / N23.1222 / W Sanfricoco   

o

 : 10919: 9065.76: 7619.9  

STD:: Cin reads only white space . So when you are giving 124.22 / N23.1222 / W San Francisco input, it reads it as four strings. So you've given enough input for all iterations.


Comments

Popular posts from this blog

Active Directory Authenticated Proxy Server with Squid or CNTLM -

java - @PluginTarget(Node.class) not registering as neo4j plugin -

python - Calculate STD manually using Groupby Pandas DataFrame -