-3

I'm trying to make a program with N number of arrays that searches matching characters of two strings and then compares the sub string with the rest of the strings. Here's the code:

int main ()
{
    int a, b, n;
    char sir[50];
    printf("Number of strings: "); scanf("%d", &n);
    if(n<=1){
        printf("The program cannot run without at least 2 strings!");
    } else {
        printf("The program will run for %d strings.\n", n);
        printf("\nString number 1: ");
        scanf("%s", &sir);
        std::string first(sir);
        cout << first;
        for(a=2; a<=n; ){
            printf("\nString number %d: ", a);
            scanf("%s", &sir);
            std::string temp(sir);
            if(!!!first.contains(temp)!!!){
                a++;
            } else {
            printf("Program stops the substring doesn't match with the last string.");
            return 0;
            }
        }
    }
}

Where I put the !!! i don't know how to code that part.

Cravenica
  • 169
  • 10
  • Why are you not using `std::cout` and `std::cin`? –  Jan 29 '17 at 20:24
  • 3
    What problem are you experiencing? What is your code doing that you are not expecting it to do? – Greg Kikola Jan 29 '17 at 20:25
  • don't know how to use std::cout and std::cin, xD I'm at begining.... – Cravenica Jan 29 '17 at 20:29
  • 1
    Take a look at [The Definitive C++ Book Guide and List](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). –  Jan 29 '17 at 20:32

1 Answers1

0

Just to answer your question: the following line should do the job:

if(first.find(temp) != std::string::npos)
Stephan Lechner
  • 34,891
  • 4
  • 35
  • 58