title: How can I traverse a string character by character
body: <p>I have a C program that receives a string from the standard input and passes it to an function written in 32-bit x86 assembly which which has to do following things:</p>
  
  <ul>
  <li>check if the string is made only of alphanumeric character.</li>
  <li>if the answer to the previous test is yes, then return the string as it is</li>
  <li>if there are some non alphanumeric characters the function has to delete them with spaces.</li>
  <li>once every character in the string has been checked the function has to return a the string without non alphanumeric characters.</li>
  </ul>
  
  <p>Here an example of what that routine has to do:</p>
  
  <pre><code>"only 4lph4numeric chars"        INPUT
  "only 4lph4numeric chars"        OUTPUT
  </code></pre>
  
  <p></p>
  
  <pre><code>"here*some*for$bidden_chars#"    INPUT
  "here some for bidden chars"     OUTPUT
  </code></pre>
  
  <p>I'm new to assembly but I know how to compare character, I think that to remove one of them is enough to substitute it with a blank space.</p>
  
  <p>The real problem is that I don't know how to traverse the string character by character; I've read something about <code>lods</code> but I've not understood how to use it.</p>