strchr

Please, what is wrong here:
1
2
3
4
5
6
7
8
9
10
11
  #include<iostream>
#include<string.h>
using namespace std;

int main(){

int field[]={2,6,4,7,5,4};
int a=strchr(field, 4);
cout<<a;
return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
#include <string>

int main()
{
    std::string field = "264754";

    std::size_t index = field.find('4');
    if (index != std::string::npos)
        std::cout << field.substr(index);
    else
        std::cout << "'4' was not found in \"" << field << '"';

    std::cout << '\n';
}
Topic archived. No new replies allowed.