c++ - Detect a blank string value -


I'm reading from an ascii file, which contains the information from the file, the file appears

1,434,341,158,498 , ... until the end of one line of pixels does not end, the next pixel line starts below 5,316,211,323,269, ... until all the pixels are covered, repeating them.

I am trying to use getline () to write these data values ​​in an array for processing. The part of my code responsible for the value is as follows:

  while (! Asciiimage.eof ()) {string pixelvalue; Getline (Eskim, Pixelview, ','); Cout & lt; & Lt; Pixelvalue & lt; & Lt; Endl; }  

Finish this by the end of the file. It works fine for a single line of pixels, though at the end of the line of pixels the cout looks like this:

  115 134 465 200  

With the difference between values ​​I will find out the difference I have tried to use it

  pixelvalue.length (); Pixelvalue.size ();  

But both of them failed. How can I find out more about this empty value of PixelValue?

if

  if (pixelvalue.length () == 0 )  

does not help, so it is not empty, but there are some spaces in it. In particular, the last element of the line is a new facet. Trim the string before checking for emptiness

  boost :: trim (pixelvalue); If (PixelView (MTP)) ...  

For more information about trimming.

Alternatively, read the entire line in the first row without any string, then read the value from the string,

  string line; While (gateline (file, line)) {// Optionally trim the line here Istingstream release (line); string value; While gateline (ash, value, ',') comment < 

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -