Language: C++


#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	string s1, s2;
	int c = 0, c1 = 0;
	cin.getline(s1,50);
	cin.getline(s2,50);
	c1 = strlen(s2);
	for (int i = 0; i < strlen(s1)-strlen(s2); i++)
	{
		
		c = 0;
		for (int j = 0; j < strlen(s2); j++)
		{
			if (s1[i+j] != s2[j])
				c++;
			
				
		}
		if (c1 > c)

			c1 = c;
	}
	cout << c1;
	return 0;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:20: error: no matching function for call to 'std::basic_istream<char>::getline(std::string&, int)'
    9 |         cin.getline(s1,50);
      |         ~~~~~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/iostream:42,
                 from a.cc:2:
/usr/include/c++/14/istream:740:5: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::getline(char_type*, std::streamsize, char_type) [with _CharT = char; _Traits = std::char_traits<char>; char_type = char; std::streamsize = long int]'
  740 |     basic_istream<char>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/istream:740:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/istream:520:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::getline(char_type*, std::streamsize) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; char_type = char; std::streamsize = long int]'
  520 |       getline(char_type* __s, streamsize __n)
      |       ^~~~~~~
/usr/include/c++/14/istream:520:26: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::basic_istream<char>::char_type*' {aka 'char*'}
  520 |       getline(char_type* __s, streamsize __n)
      |               ~~~~~~~~~~~^~~
a.cc:10:20: error: no matching function for call to 'std::basic_istream<char>::getline(std::string&, int)'
   10 |         cin.getline(s2,50);
      |         ~~~~~~~~~~~^~~~~~~
/usr/include/c++/14/istream:740:5: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::getline(char_type*, std::streamsize, char_type) [with _CharT = char; _Traits = std::char_traits<char>; char_type = char; std::streamsize = long int]'
  740 |     basic_istream<char>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/istream:740:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/istream:520:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::getline(char_type*, std::streamsize) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; char_type = char; std::streamsize = long int]'
  520 |       getline(char_type* __s, streamsize __n)
      |       ^~~~~~~
/usr/include/c++/14/istream:520:26: note:   no known conversion for argument 1 from 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'std::basic_istream<char>::char_type*' {aka 'char*'}
  520 |       getline(char_type* __s, streamsize __n)
      |               ~~~~~~~~~~~^~~
a.cc:11:21: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
   11 |         c1 = strlen(s2);
      |                     ^~
      |                     |
      |                     std::string {aka std::__cxx11::basic_string<char>}
In file included from a.cc:3:
/usr/include/string.h:407:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
a.cc:12:36: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
   12 |         for (int i = 0; i < strlen(s1)-strlen(s2); i++)
      |                                    ^~
      |                                    |
      |                                    std::string {aka std::__cxx11::basic_string<char>}
/usr/include/string.h:407:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
a.cc:12:47: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
   12 |         for (int i = 0; i < strlen(s1)-strlen(s2); i++)
      |                                               ^~
      |                                               |
      |                                               std::string {aka std::__cxx11::basic_string<char>}
/usr/include/string.h:407:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~
a.cc:16:44: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'const char*'
   16 |                 for (int j = 0; j < strlen(s2); j++)
      |                                            ^~
      |                                            |
      |                                            std::string {aka std::__cxx11::basic_string<char>}
/usr/include/string.h:407:35: note:   initializing argument 1 of 'size_t strlen(const char*)'
  407 | extern size_t strlen (const char *__s)
      |                       ~~~~~~~~~~~~^~~