CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004
    Posts
    5

    Question ignoring punctuations and spaces when working with arrays

    how do you ignore spaces and punctuations when working with arrays?

  2. #2
    Join Date
    Feb 2004
    Posts
    81
    Again an incomplete question.
    What I interpreted is that you want to eat some punctuation characters from the array of characters provided to you by the user. You can define a function like below to do that. I am assuming you only want to delete one character, although you can modify the code easily to delete all punctuation characters.

    Code:
    void eatchar(char* arr,char ch) {
        int i = 0, j = 0; // to and from indexes
        while(*(arr + i) = *(arr + j++)) {
            if(*(arr + i) != ch) ++i;
        }
    }
    while(true)
    cout<<"C++ is divine\n";

    Feroz Zahid

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured