Matching strings in an array

Problem Statement

In this code we are matching the strings in the array with words you type, basically making sure that the word you typed in is there in the array, it is like a bool code.

User Story

As a Developer, i want to match words with the words in the storage**, so that** i can improve my algorithms.

Algorithm

Program

#include <cs50.h>
#include <string.h>
#include <stdio.h>

int main(void)
{
    string str[]={"Hi","Namaste","bonjour","hola"};

   string strings = get_string("enter the words:  ");
    for(int i=0;i<4;i++)
 { if (strcmp(str[i],strings)==0){
        {
            printf("found\n");
            return 0;
        }
    }
    printf("not found\n");
    return 1;
}
}
10
Subscribe to my newsletter

Read articles from Aadhithya Bharadwaj BM directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Aadhithya Bharadwaj BM
Aadhithya Bharadwaj BM