Quantcast
Channel: CoderzHeaven » Iostream
Viewing all articles
Browse latest Browse all 4

How to search for a particular character in a C++ string ?

$
0
0

Hi,

In order to search for a particular character in a C++ string, use the following code.

#include <iostream>
#include <cstring>

using namespace std;

int main() {

  const char *testStr= "coderz@heaven";

  const char *temp;

  // Searching
  temp = strchr(testStr, '@');

  if(temp )

      cout << "Found";

  return 0;
}

Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles



Latest Images