c++ - Integer not incrementing correctly -


OK, I am currently trying to implement an MIPS program counter, in which I stored a hex value Includes where the program is on (program counter). But the point is that the following codes will not go before one digit because this increase is 0,4,8,0 etc., where repeats 0 should be equal to 10.

This source works if str_pc is basically set to 00000010 but otherwise it will not.

  #include & lt; Iostream & gt; # Include & lt; iomanip & gt; # Include & lt; Sstream & gt; #include & lt; String & gt; #include & lt; Map & gt; using namespace std; String str_pc = "00000008"; Int main () {int temp_pc; Stringstream ss; SS & lt; & Lt; Hex & lt; & Lt; Str_pc; SS & gt; & Gt; DCD & gt; Temp_pc; Cout & lt; & Lt; "Temp_PC:" & lt; & Lt; temp_pc & lt; & Lt; Endl; temp_pc = temp_pc + 4; Ostringstream SS1; SS1 & lt; & Lt; Hex & lt; & Lt; Temp_pc; String x (ss1.str ()); Str_pc = x; Stringstream SS2; SS2 & Lt; & Lt; Hex & lt; & Lt; Str_pc; SS2 & gt; & Gt; DCD & gt; Temp_pc; Cout & lt; & Lt; "Temp_PC:" & lt; & Lt; Temp_pc & lt; & Lt; Endl; temp_pc = temp_pc + 4; Ostringstream SS3; SS3 and LT; & Lt; Hex & lt; & Lt; Temp_pc; String y (ss3.str ()); Str_pc = y; Cout & lt; & Lt; Str_pc & lt; & Lt; Endl; }   

What am I doing wrong on some light shine?

There is a representation of a number (integer) in hexadecimal string. SS & lt; & Lt; Hex & lt; & Lt; Str_pc; SS & gt; & Gt; DCD & gt; Temp_pc;

This does not understand. In the first line, the hex modifier does not work on the string, then it is useless here. On the other side you use int on the second row, so you should put the hex modifier to interpret the string as a hexadecimal number; SS & lt; & Lt; Str_pc; SS & gt; & Gt; Hex & gt; & Gt; Temp_pc;

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -