c++ - Adding a char into a temporaryChar outputting garbage -


I am making a method in which I load the notepad file in random data in it, and I have to read the character through it Character. Then I check whether this character is a digit or a letter and so on and so forth.

I have invented a method called a deed (f) in which it accepts the character that is loading and checks what it is between 0 and 9 If it is a digit, then it has been added to a newly created char tempString . Problem is that whenever I add it four tampstring the first number comes out properly, but the rest (from 1 to 5 in my dummy file) as garbage Comes.

What could be the reason? Below you have code and output


coding
  token Lexer :: MillTetoken () { Four f; Four temporary string; Std :: ifstream input ("dummyData.txt"); While (input) {input.get (ch); If (isDigit (ch)) {tempString + = ch; Cout & lt; & Lt; TempString & lt; & Lt; Endl; Colonel ++; } And if (f == '\ n') {cout & lt; & Lt; "\ NThe new line \ n" & lt; & Lt; Endl; Line ++; Colonel = 1; } And {cout & lt; & Lt; "Error" & lt; & Lt; Endl; } Offset ++; Cout & lt; & Lt; "Cry" & lt; & Lt; Row & lt; & Lt; "Columns" & lt; & Lt; Colonel & lt; & Lt; "Offset:" & lt; & Lt; Offset & lt; & Lt; Endl; } Return token :: tkDigit; }   

waste data

You declare tempString as a letter instead of a string. Adding a character for it does not change the character by adding it to a string; It adds ASCII value of the ch to the already tempString , and creates some other character value.

Try std :: string tempString;

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -