View Single Post
Join Date: Jun 2008
Posts: 92
Reputation: JackDurden is an unknown quantity at this point 
Solved Threads: 0
JackDurden JackDurden is offline Offline
Junior Poster in Training

Re: Using string as char array

 
0
  #4
Dec 2nd, 2008
Well that sort of works but if the char I want to delete/erase is at the end of the string my compiler crashes. I dont understand how to delete/erase a char that is not an alphanumeric type.

  1. int i=0;
  2. string aWord = "abcdf!";
  3.  
  4. while(aWord[i])
  5. {
  6. if(isalpha(aWord[i]))printf ("character %c is alphabetic\n",aWord[i]);
  7. else
  8. aWord.erase (i, 1);
  9. i++;
  10. }
  11. cout<<aWord;
Last edited by JackDurden; Dec 2nd, 2008 at 3:56 pm.
Reply With Quote