Searching For A Substring

Hi guys. I'm working on a program that reverses the string the user inputs and displays it. The other requirement is for it to search if the word "junk" is in the original input or not. I'm having issues in searching for the word junk. Here's my code so far:

#include <stdio.h>
#include <iostream>
#include <cstring>
using namespace std;


void reverse(void)
{
char c;
if((c = getchar()) != '\n'){ reverse(); }
putchar(c);
return;
}


int main(void)
{
const int SIZE = 100;
char c[SIZE];
cout << "Enter a line of text below: " ;
reverse();
putchar('\n');
char *strPtr = NULL;
int index;

for (index = 0; index <c ; index++)
{
if (strPtr != NULL)
break;
}

if (strPtr != NULL)
cout << c[index] << endl;

else
cout << "The word junk was not in the original text. \n" ;

system ("pause");
}
There is such a function as strstr in C (and in C++) that does the required searching.
I came across the function...but any guidance on how to use it?
You can find its description for example here in this forum.Ttry to do this yourself.
Topic archived. No new replies allowed.