Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are several problems. As has already been mentionned, you return from the middle of the nested loop: certainly not what you want to do. Also, before the loop, you read into matrix[lines][cols]: this is undefined behavior, since you've never initialized lines and cols. (Typically, you wouldn't even define them until in the for, e.g.: for ( int lines = 0; lines &lt; 30; ++ lines ) for ( int cols = 0; cols &lt; 30; ++ cols ) .) Still, the line is syntactically valid, and reads the first non-blank char from the input (in your case, the initial #). And writes it somewhere, although it's anybody's guess where.</p> <p>Some additional comments: -- The argument to readfile should be char const*, and not char*. Or even std::string const&amp;.</p> <p>-- I'm not sure what you're trying to read into the matrix: where do the 30 come from in its definition? And shouldn't it be "int matrix[x][x]", or something along those lines. Or more likely: "std::vector >".</p> <p>-- You're reading integers (or as written, a single char); precision has no effect. It also has no effect on input.</p> <p>-- And what is "ifs.setf(ios::fixed, ios::showpoint)" supposed to do. (As it happens, it almost certainly sets the floating point format to its default---and not to fixed---, although I think the behavior is formally undefined.) Not that it matters; these flags also have no effect on input.</p> <p>-- The "while(!ifs.eof())" is also certainly wrong. The expression ifs.eof() is only reliable <em>after</em> an input operation has failed.</p> <p>In addition, you'll need some special handling for the first non-comment line, and some special handling for the first character in each line.</p> <p>-- James Kanze</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload